Ive just recently started using jquery validation engine, and I was wondering:
Im in a scenario where I only want to validate a field only if another field isnt empty. I have applied the condRequired validation rule to this field, which works fine, but all other rules after the condRequired get fired. For example:
<input type="password" id="current-password" name="current-password" placeholder="Current Password" class="validate[condRequired[password],ajax[ajaxValidateUserPassword]]">
<input type="password" id="password" name="password" placeholder="New Password" class="ajax[ajaxValidateUserRegistration]]">
If a user decides they want to update their password, they must enter the current password. However I only want to validate the current password, if the user has entered a new password. So I have:
validate[condRequired[password],ajax[ajaxValidateUserPassword]]
as the validation rule on the current password. The problem is: even if the user hasn't entered a new password,
condRequired[password]
will fail, but
ajax[ajaxValidateUserPassword]
still gets fired.
Is there a way to get the
ajax[ajaxValidateUserPassword]
validation rule to get skipped if the
condRequired[password]
rule fails? Idea is I dont want to bother with ANY validation on the current password if no new password has been entered
Thanks!