开发者

jQuery: How to stop the change() event from firing from the blur() handler?

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


I've found a workaround to the problem:

  • handling the validation only after the change event
  • triggering the change event in the handler or the blur (in case)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜