[whatwg] Three concerns regarding HTML5 form validation

Matias matiasnu at gmail.com
Mon Sep 26 04:58:52 PDT 2011


Hi,

I don't know if this can/should be specified in the spec or if it's up to the browser implementors but here's some concerns I have regarding HTML5 form validation;

1) Is there a reason why native form validation seems to be tied to the click of the submit button? Submitting the form using JavaScript does not seem to trigger HTML5 form validation in either Firefox, Opera or the Webkit browsers (I haven't checked how IE10 behaves yet). To me this seems like an unnecessary limitation.

2) How about adding a method to programmatically display the native validation error messages instead of waiting for the form submit click? We already have a way to (more or less) detect if the form is valid or not, but no way of forcing the native validation error messages to render without using some submit button click hack.

3) Should there be a way of detecting if the browser actually understood all input element types? Browsers believe that a form is valid even when it contains invalid data for input types the browser doesn't understand. (Like the string 'asdf' in an input type=number field in Firefox.)

So checking if the browser has a checkValidity method is not a guarantee that the form validates according to the HTML5 specified constraints. If there was a method or property like form.containsUnknownInputs and maybe element.isUnknownInput (not the best names, but you get the idea) we could determine the best way to handle further validation.

I would love to hear your opinions on these issues which to me are quite serious impediments for a smooth validation implementation experience for web developers.

Best regards,
Matias Larsson


More information about the whatwg mailing list