Reputation: 724
I have the following scenario:
$("#element").blur(validate).change(onElementChange);
The validate() function should prevent the change event from firing, if the value of the #element is not valid. I cannot add the validate to change, because it needs to validate on blur too. If add the validate() to both events, the alert with the validation error will pop up twice.
So, the my question is, can I stop the change event from firing from the handler of the blur event?
Also if you have a different solution (without using plugins), i would like to hear it.
Thanks
Upvotes: 2
Views: 2172
Reputation: 724
I've found a workaround to the problem:
Upvotes: 1
Reputation: 6322
can't you call the onElementChange function inside your validate function when it returns valid.
Upvotes: 0