-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
HTML5 form support #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Copy of an email conversation on html5 validation: I'm about to start adding some client-side validations to an (NB: jQuery-validation and HTML5 have different opinions on one -James the plugin already reads normal DOM attributes, so as long as html5 names match methods provided by the plugin (required, min, max, minlength (not sure here), maxlength (yeah...), it works already. Whats missing is disabling the html5 validation when the plugin is active, to avoid interference. Support for the type-attribut is really the interesting part. The plugin supports url and email, but not specified via type="...". The pattern method could be added very easily, once present, it'll get picked up automatically. In regards to the title attribute: If nothing more specific then the generic message for a given message is provided, the title-attribute, if present, gets used. So if you do $.validator.addMethod("pattern", function(value, element, regex) { ... }) (without the message argument), it should work very similar to html5. And while at it, adding a bit of aria support (like aria-required) would be really easy, too. Eventually I'll work on this myself, but your help to get this done faster is very welcome! Regards
There are a few things I didn't see in the plugin (though I may not
The plugin validates on blur, with a few restrictions outlined here: http://docs.jquery.com/Plugins/Validation/Reference#Validation_event Whats the point of the plugin setting these properties? Does any kind of mixed mode really make sense?
I'm not entirely sure what the benefit of all of the different Additionally, HTML5 validation will fire an oninvalid event when Oh, and one last thing: there is a formNoValidate attribute on <input validation for the form. See http://www.w3.org/TR/html5/association-of-controls-and-forms.html#attr-fs-novalidate |
Thanks for the contribution. I ended up adding the one line myself, but more importantantly, along with a change to also support reading the type-attribute. Thanks to getAttribute that even works in IE6. |
…nd reading the type attribute. Fixes jquery-validation#7
I added support for HTML5 by automatically attaching the required attribute to the form. I considering making it try to detect the context, but then realized that the issue might be larger than just type="email", so it applies to every form.
Sorry for two commits, just getting the hang of this.