How to make Id card pattern? | Sololearn: Learn to code for FREE!

0

How to make Id card pattern?

I want to make Id card 15 digit pattern in input tag. If numbers exceed limit 15 then it show error if numbers less than 15 then it show error msg

12/20/2019 12:51:56 PM

Muzamil Qasim

2 Answers

New Answer

+1

What value do you use for the 'type' attribute of the <input>? For limiting maximum number of characters allowed you can set 'maxlength' attribute e.g. maxlength = "15" But this only limits the maximum number of characters (prevents entering more than the limit - 15). And this doesn't work if <input> 'type' attribute is number. One way or another, you will have to code the validation to check when the input was less than 15 characters.

+1

var input = document.getElementById(“input”); input.onchange = function(){ if(input.value.length!=15){ errorFunction(); }; };