Suppose i have two text fields t1 and t2 and when T1 is entered we need to remove
validation for t2 and when T2 is entered we need to remove for T1
Iam using addClass() and removeClass() methods
if($("input:text").val()!=''){
$("#txt1").attr('class','validate[optional] ');
$("#txt2").attr('class','validate[optional] ');
}
But My problem is when i enter in “txt2 ” still the “txt1” is asking for validation and the reverse is working
.val()will get the value of the first element in the set, that’s why the reverse works.Instead look if there are any non-empty ones, like this: