Html code for validating forms
If you need to support older versions of IE prior to IE10 you won't find any of those support form validation either.
So, what can you do if you have to support browsers that don't have support for form validation yet?
But the great thing about them is that they all degrade gracefully.
So if an older browser doesn't support them, the fact that they're in the HTML won't 'break' anything, they’ll just be rendered as an .
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.
They also help with accessibility, as the text in the label will be read out to screen reader users: it can therefore be useful to indicate required fields by adding ‘required’ to the label text, as I’ve done above.
We can achieve this by adding a pattern attribute to the 'Name' field, setting it's value to the regular expression we want the data to be compared against: The text in the title attribute is then appended to the built-in validation message: Note that some screen reader / browser combinations might lead to the title attribute being read out in addition to the aria-describedby text, so watch out for this e.g.
I found that using NVDA with IE10 caused the title attribute and the aria-describedby element's text to be read out, but using NVDA with Chrome and Firefox didn’t exhibit this behaviour. Later on we’ll revisit this and show you one solution using CSS3.
One option is to not do anything and rely on your server-side validation only.
This would require no extra work on your part, but would the UX for those using unsupported browsers be satisfactory?