Friday, December 12, 2008

jQuery: Conflict free events

I had to validate an input, both onBlur and when the user pressed enter. If there was an error, in both cases, an alert would pop up. The problem was that when the user clicked 'ok' on the alert, the field would lose focus and cause the blur event to fire, and thus cause another alert to pop up. I only wanted one alert per error, so i made this little plugin to solve this problem.

To use this plugin, you can pass in a hash with 2 keys: {blur: function(){}, enter: function(){}}, or a single function that you want run both onBlur and onEnter.

Example usage:


  1. Nice one. Thanks for sharing the idea.

  2. THANK YOU!!!!!!! I have been dying trying to figure out how to fix this