views:

20

answers:

1

Hi,

I am using Jquery ui accordion , in that i have a text box as a accordion header , now when i am trying to type a space in text box accordion change and changestart event fire so how would i prevent this thing while typing space in a input box

+1  A: 

use

within a keydown or keypress or keyup event handler. You can check the keyCode or even better the value of which from the event object there and execute both functions from above.

Alternativly, you can just return false; which actually will trigger the same functions for you.

Example:

$('input:text').bind('keypress', function(event){
   if(event.which === 32)
      return(false);
});
jAndy
this wont allow me to type space in a textbox
hunt
Done !! using following code thanks if (event.which == 32) { event.stopPropagation(); }
hunt
@hunt: yes indeed you're right. My bad. You just need to prevent the `event bubbling` in that case.
jAndy