Onchange Event Is Not Working Well
Solution 1:
Programmatically changing the value doesn't fire a change event, that only occurs if the user focuses the element, changes the value and then puts focus elsewhere.
Options are to manually call the onchange listener, dispatch a change event on the element, or manually bubble the change event by going up the DOM looking for parents with an onchange listener and calling them.
Here is an answer that seems to fit the bill: trigger onchange event manually
Some links:
- MDN dispatchEvent (standards compliant): https://developer.mozilla.org/en/DOM/element.dispatchEvent
- MSDN fireEvent (IE proprietary): http://msdn.microsoft.com/en-us/library/ie/ms536423(v=vs.85).aspx
Solution 2:
If you want to capture every change use the keydown event. onChange only fire after an input is blurred if I remember correctly.
Solution 3:
function codeThatAltersTextFieldProgrammatically() {
/* ... code ... */textFieldChangeEventHandler();
};
function textFieldChangeEventHandler(){
/* .... */
}
Solution 4:
well currently according to your code, when you get out of the text box the event works,
you need to try OnKeyPress check it here http://jsfiddle.net/EBMyy/
see this code
$(document).ready(function(){
$("#Textbox").keypress(function(){
alert("Text Changed");
});
});
Post a Comment for "Onchange Event Is Not Working Well"