-
Notifications
You must be signed in to change notification settings - Fork 125
Home
I opened this up to make room for design discussion. There are major changes coming to the 1.0 API. The most important change will be the public event API.
h5Validate is an HTML5 polyfill that allows you to use some of the most practical and best features of the HTML5 form validation spec today, in all major browsers dating back to IE6. Specifically, it adds support for the pattern and required attributes, which, on their own, cover most of the validation requirements you encounter.
We plan to support all of the new HTML5 input types and validation methods in the specification. Progress on this has been slow as we've waited for various browser implementations to implement and stabilize the new HTML5 features.
Trigger the 'validate' event to validate either a whole form, or an individual field. (Only works for individual field right now).
Listen for 'validated' to get back the ValidityState.
Listen for 'formValidated' to get back the ValidityState collection for the whole form.
Using the event API, it will be easier to add asynchronous operations (such as custom Ajax validation).
h5Validate currently supports three validation types: pattern, required, and validValues. We'll be adding more of these, particularly those that support the new HTML5 input types -- what's better, though: You'll be able to pass in your own custom validation types in the configuration, and bind them up to the HTML with your own class names.
We really want to support all of the new input types, but some of them have custom browser UI that is tricky to override.
It would be great if we could fall back on the native browser validations to determine whether or not an input is valid, but currently, there is no way to do this without bringing up the native browser error messaging, which does not allow for custom styling. This effort will be a high priority going forward, but it is stalled right now because it requires some revision to the specification, browser implementations, and will require some browser bug fixes (there are still open browser bugs in multiple browsers for false positive errors).
h5Validate does not currently attempt to support every aspect of HTML5 forms. Selecting input type="email" will not automatically select the email validation pattern, and so on. If you can, please help create test cases for new input types so that this phase of development can move forward faster.
h5Validate ignores the novalidate and formnovalidate attributes, because it uses them to override native browser validation behaviors (most of which do not conform to inline form validation best practices at this time, and do not allow enough flexibility in how error messages get displayed). As far as I know, currently, this is the ONLY way to override native browser validation behaviors.
In order to prevent h5Validate from attempting a validation, add the .novalidate
class to elements you want to skip.