tags:

views:

196

answers:

1

Hi,

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

A: 

can't you call the onElementChange function inside your validate function when it returns valid.

Josh
unfortunately the onElementChange does some updates which should be made only if the data is modified.
egyedg