Ken Carter Ken Carter - 5 months ago 11
Javascript Question

A more sensitive 'OnTextChange'...?

I am building a page where I want an update button that is hidden until such time as the user has altered some data on the page. Therefore my first thought was to simply on my text box to add 'OnTextChanged' and then throw a Visible=true to my update button and the user would be aware they hand information on the screen that needed to be saved before they left or they would otherwise loose it.

However, OnTextChanged doesn't trigger when you start adding data to the text box nor even when you leave the text box and go to another. In fact it doesn't trigger until you do something else on the page, then it fires and my button then appears and the update can be executed by clicking on the button.

I would MUCH rather have this triggered with the first additional character space or digit is added or removed from a textbox or element rather than wait for such an event as the only thing I intend to do with these trigger points is to activate the update buttons visibility so the user can update when they are ready to. The update routine then re-hides the button waiting for the next bit of data to change to re-light the button once again.

Anyone have any suggestions on how to get this to do what I'm wanting to do here? Just wanting a more sensitive OnTextChanged function.



Try to use the event onKeyPress. It should be triggered each time the user types a character in an input.

Here you have more information