Hello all
I need help with the following.
I have a secondary email address field in my form that is optional.
I do validations on the field but I want to validate the field only if something has been typed into it.
Here is my code:
{ input: ‘#secondaryEmail’, message: “Please enter a valid email for your secondary email address”, action: ‘keyup’, rule: ’email’ },
{
input: ‘#secondaryEmail’, message: “Your secondary email address must be different from your primary email address”, action: ‘keyup’, rule: function (input, commit) {
if (input.val() === $(‘#email’).val()) {
return false;
}
return true;
}
},
I want this validation to happen only if the user types something in the field.
Suggestions?