HTML Input restrictions not working

Hi there,
I have some input restrictions in a form that are not working, I mean, I can type anything in the fields and submit despite the restrictions:

<label for="username">Username:</label><input id="username" type="text" name="username" placeholder="User Name" pattern="[a-zA-Z0-9_-]{5,10}" title="No special characters other than - and _">

I’m I missing something ?

What browser are you using. The pattern attribute was added in HTML 5 which only became the latest standard in late 2014 so there are still a lot of browsers around that don’t support it.

Chrome :frowning: I’t was suppose to work

And the page is marked up and served as HTML5?


It ought to work-- I’ve copied your code and plugged it into a page I was working on. Typing &&foo^& definitely stopped it from submitting, also Foobarbazquux. I did have to hit submit rather than simply blur the input.

Seems to work in latest versions of chrome,Firefox and IE.

Yes Mittineague, it is.

Hmmm, according to Can I use Chrome has supported it since version 10.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.