Hi, I have a question regarding the range of input field. Suppose, I created input field (debit card , in which I want 16 numbers , and space between every four number, means user easily put their debit card number which is of 16 bit numbers with space ), so I put input field = "number", but I easily put those numbers, but there is no restrictions, that only 16 numbers should be there ,( with space, space should be after every four number), how should do this? how to put these restrictions that only 16 numbers should be in input field and space after every four number?
If you are only concerned with modern browsers, the HTML5 input element has a pattern attribute that you can use to specify a regular expression that must be adhered to.
If you need to support legacy browsers, then you'd need to write script that checks the pattern.
But to be honest, I wouldn't do it this way. As long as you get the 16 numbers, what do you care about the spaces? I'd let the user enter the 16 digits any way they wanted; with no spaces, with dashes, with any non-digit characters, whatever. Make it easy on the user, and write your code to make sure you get 16 digits -- anything else is unimportant.