I have been working on some form validation in jQuery. Everything was going nicely and then I realised I need to do a password and confirm password validation method. I have so far:
'dotwPassword': function () {
var info = $('.dotwPassword');
var ele = $('#dotwPassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
'dotwConpassword': function () {
var info = $('.dotwConpassword');
var ele = $('#dotwConpassword');
if (ele.val().length < 6) {
jVal.errors = true;
info.removeClass('dotwCorrect').addClass('dotwError');
ele.removeClass('dotwNormal').addClass('dotwWrong');
} else {
info.removeClass('dotwError').addClass('dotwCorrect');
ele.removeClass('dotwWrong').addClass('dotwNormal');
}
},
Can anyone show me how to add in a match for password on conpassword so these 2 fields have to be the same in order to proceed and send the form?
Thanks in advance
Richard
Don’t you just need to add the following test to both functions:
You could add that to the same if test you already have:
Or handle it separately.