ericelliott / h5Validate

An HTML5 form validation plugin for jQuery. Works on all major browsers, both new and old. Implements inline, realtime validation best practices (based on surveys and usability studies). Developed for production use in e-commerce. Currently in production with millions of users.
576 stars 125 forks source link

Password and Confirm Password Validation #86

Closed faizanqadri closed 9 years ago

faizanqadri commented 10 years ago

h5validate: Is there a way to do validation for two input fields for exact match? Kindly let me know how to do that?

ericelliott commented 10 years ago

Not built-in, but you can set the pattern attribute of the second password field to be the literal text of the first password field when the first one blurs.

zenopopovici commented 10 years ago

Had the same issue, this is what I used and it works perfectly:

// Make Passwords Match
$('#js-register-password').blur(function(){
    $('#js-register-passwordconfirm').attr('pattern', $('#js-register-password').val() );
});
ericelliott commented 9 years ago

:+1: