Form validating

Libraries such as Modernizr can help with HTML5 feature detection, but you can always write your own code if you don't want to include another Java Script library: In this article we've walked through applying HTML5 form validation to a booking form client-side without using any Java Script, and pointed out some accessibility issues to be wary of.

We then looked at how new CSS3 pseudo-classes can be used to give visual cues to the user as to which fields are required and options, and which contain valid or invalid data.

In tandem with the new input types and attributes provided by HTML5, CSS3 gives us some new pseudo-classes we can use to provide visual clues to the user as to which form fields are required, which are optional, and which contain validation errors.

Required fields can use the Now, in addition to showing the help text when the input field receives focus, we'll also show the help text when the input field's value is invalid.

This would require no extra work on your part, but would the UX for those using unsupported browsers be satisfactory?

View example » Parsley is shipped with more than a dozen useful validators.

If not enough, use the awesome Parsley extra Ajax validator or tons of other extended validators provided by the community.

I’m also using the WAI ARIA attribute now, so if we leave ‘required’ in the label tag screen reader users will have ‘required’ read to them twice, which they could find rather annoying.

A word of warning though: not all browsers implement the attribute accessibly, so it might not be picked up correctly in certain browser / screen reader combinations.

Search for form validating:

form validating-87

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “form validating”