I have an e-mail field, and a confirm e-mail field. I need to validate both of them to make sure their values match.
Is there a way to add a rule to match those two fields?
I have an e-mail field, and a confirm e-mail field. I need to validate both of them to make sure their values match.
Is there a way to add a rule to match those two fields?
You could use the equalTo method:
$('#myform').validate({ rules: { email: 'required', emailConfirm: { equalTo: '#email' } } }); messages attribute. I strongly suggest you to reading the documentation of the jquery validate plugin which contains all the necessary details: jqueryvalidation.org/documentationYou can also do this on the second field:
class="required email" equalTo='#email' U can use this
email: { required: true, email: true }, c_email: { required: true, equalTo: "#email", minlength: 5 }, <div class="form-row"><span class="label">email</span><input type="email" name="email" class="required" id="email" /></div> <div class="form-row"><span class="label">Confirm email</span><input type="email" name="c_email" id="c_email" /></div>