html - How can I make the number input only accept a certain ammount of charaters? -
I am registering my ID for people cheaper. All IDs are 17 characters long.
How can I make it so that the number of numbers they post should be up to 17 characters?
Example: ID number 76561197969408686
The input field can only accept 17 long IDs
EDIT: If you have the same problem with Chrome , Please see my answer below
You can use the pattern-attribute, Returns the output:
& lt; Input pattern = "[0- 9] {17}" expected title = "17 characters are required" & gt; In Javascript, you can test it like this:
var input = getElementById ("yourID"). Value; If (input.match (/ ^ [0-9] {17} $ /)! = Null) {// true} In PHP, it should work like this: < / P>
if (preg_match ("^ [0-9] {17} $", $ _POST ['userid']) === 1) {// right} else {dead (please 'Your Identity'); }
Comments
Post a Comment