Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match two fields with jQuery validate plugin

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?

like image 420
Steven Avatar asked Feb 28 '11 20:02

Steven


Video Answer


2 Answers

You could use the equalTo method:

$('#myform').validate({     rules: {         email: 'required',         emailConfirm: {             equalTo: '#email'         }     } }); 
like image 146
Darin Dimitrov Avatar answered Oct 03 '22 23:10

Darin Dimitrov


You can also do this on the second field:

 class="required email" equalTo='#email' 
like image 36
Jazzy Avatar answered Oct 03 '22 23:10

Jazzy