You can add a normal event listener to your input field like so. (using jQuery)
$(myTextControl).change(function() {
...
/* do appropriate event handling here */
...
});
Ok considering that the javascript which changes the input value isn't controlled by you it gets difficult. You are left with two options:
1.) Crossbrowser compatible: Implement polling of input value with a function which continuously checks if the value changed. (Something along these lines).
//at beginning before other scripts changes the value create a global variable
var oldValue = myTextControl.value;
function checkIfValueChanged() {
if(myTextControl.value != oldValue) {
$(myTextControl).trigger("change");
clearInterval(checker);
}
}
//every 500ms check if value changed
var checker = setInterval('checkIfValueChanged()', 500);
Note: If your script or the user can change the value too you must implement something to catch this in order not to trigger the change event multiple times.
If the value can change multiple times by the external script just let the interval function run instead of canceling it and just update oldValue;
2.) AFAIK Not supported yet by all browsers (? test it on the ones you need to support)
You could bind to a special DOM Level 3Event: DOMAttrModified
(in Firefox, maybe others too I think Opera has it too, Safari??, Chrome??) and in IE of course it has a different name propertychange
(and is proprietary and different from the W3C behavior)
Now ideally you could combine the two options and check if support for DOMAttrModified
or propertychange
is there and use accordingly or fallback to the polling solution.
Reading links
W3C DOM Mutation Events
W3C DOMAttrModified Event
MSDN DHTML propertychange Event
jQuery CSS Property Monitoring Plug-in updated
Last link is some guy which basically already made a jQuery plugin doing the things described by me (untested by me, provided just as a reference)