[SOLVED] How to validate more than two fields?

gabedaly 14 Jun, 2011
I am able to validate two fields using Max's code (checkequal)from another post. But, how can I validate two more fields on the same form. For example:

password
confirm_password
AND
email
confirm_email

Thanks,
Gabe
GreyHead 14 Jun, 2011
Hi Gabe,

Where's the other post?

Bob
GreyHead 14 Jun, 2011
Hi Gabe,

This can be done by adding a class to your element:
validate['%checkEqual2']
and adding a JS snippet using a load JS action:
function checkEqual2(el){
  if (el.value != $('confirm_password').value) {
    el.errors.push("Passwords are not the same!");
    return false;
  } else {
    return true;
  }
}
Where "confirm_password" is an id for the password confirmation field.

Bob
gabedaly 15 Jun, 2011
Thanks Bob, I should have known better. Works like a charm.
This topic is locked and no more replies can be posted.