Friday, November 12th, 2010

HTML5 forms validation in Firefox 4

Category: Firefox, JavaScript

<p>Mounir Lamouri looks at native browser-side form validation in Firefox4  – while re-iterating the need for re-validating on the server-side too. The objective of the browser-side form validation is to relieve JavaScript of the need to do a lot of basic form checking. Lanouri writes:

”All new input types introduced with HTML5 forms except search and tel benefit from internal validation.
Firefox 4 is going to support email and url and the validation will check if the value is a valid email or url respectively.”

Also discussed is added pattern matching support and a new pseudo-class that applies on submit controls when a form has an invalid element.

Related Content:

5 Comments »

Comments feed TrackBack URI

Let’s hope there are no errors in the validation.

Comment by ebdrup — November 12, 2010

I want a form validator that will tell me if I’ve entered a captcha correctly before submitting the form.

Comment by okonomiyaki3000 — November 12, 2010

Only way to enter captcha correctly is to present captcha correctly to user. Many sites are horrible in doing this.

Comment by Liburn — November 14, 2010

ebdrup,

Yeah, my first thought when I heard about form validation in HTML5 is that those of us who’ve spent so much time refining our custom validation rather than picking simple examples off the ‘net are going to be more than a little careful before we give up that control to the browser.

With that said, I trust the browser vendors a great deal more than most web developers with this task, and I’m sure the usual suspects (and a few of us) will put the new validating browsers through a gauntlet of tests and find their edge cases.

There’s a bigger problem with email and IRI fields than correctness, though. There’s a lot of room for opinion when both standards are fairly permissive. Email addresses, for instance, allow names, comments, and a variety of other things that don’t actually serve to route an email from outbox to inbox. Just look at the stuff that’s *valid* according to the spec: http://www.dominicsayers.com/isemail/results.php. Many of those are totally legal but either likely to be prevented by email providers or a sign of some kind of shenanigans.

When it comes down to it, we’re going to probably want more control than canned field types promise. That said, if this lowest common denominator is embraced by the lowest common denominator developers, we’re in for a big improvement in the broader web. So I’m just as excited to see the browsers taking this up as I was when I first heard about the proposal.

Comment by eyelidlessness — November 15, 2010

excellent news…

Comment by vanetino — November 20, 2010

Leave a comment

You must be logged in to post a comment.