mailgun / validator-demo

Mailgun email address jquery validation plugin http://mailgun.github.io/validator-demo/
Apache License 2.0
257 stars 80 forks source link

HTML5 constraint validation #17

Open kevinmickey opened 8 years ago

kevinmickey commented 8 years ago

It might make sense to use HTML5 constraint validation, in particular setCustomValidity().

See https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Constraint_API's_element.setCustomValidity()

msigley commented 8 years ago

There are only currently two client side validations done in the script: https://github.com/mailgun/validator-demo/blob/master/mailgun_validator.js#L77-L80 Both of which are very fast because they only use string functions.

We actually don't want to completely validation the domain name on the client side to take advantage of mailgun's "Did you mean?" feature to help the user correct their input, otherwise the built in browser email validation in the HTML5 Validation API would be a nice optimization to the script.

Safari currently doesn't actually display the validation message to the user when it blocks the form submission: http://caniuse.com/#feat=form-validation Until that is resolved it is probably best to not use setCustomValidity() to avoid displaying two error messages to the user.