html5 - HTML Pattern - regex not working -


i'm trying pattern attribute first time, , can't work (my browser support it, though).

right have:

input type="text" pattern="[a-za-z0-9]{6}" name="formname" 

the first problem is doesn't notify me if it's blank; second problem if type in something, won't accept it. want accept alphanumeric characters , 6 characters length. tried forward slashes , few other variations.

as duikboot pointed out, right way is:

<input type="text" name="formfield" pattern="[a-za-z0-9]{6}" required> 

the required attribute causes validation fail, when field empty.
pattern attribute defines regex test against, when field not empty.
(your initial pattern seems work fine.)

more info can found here.
simple enough not require demo, nonetheless can find 1 here.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -