I have list of input fields. In which some are readonly fields.
I am using .keyup() event to trigger when something changes in input field.
But it won’t effect for readonly field.
Somehow i want to change those fields also .
Any help?
I have list of input fields. In which some are readonly fields. I am
Share
If you call
focuson a readonly input field, thenkeyupevents will fire. However, typing in that field won’t change its value (afterall, it’s read-only). Perhaps what you need is to listen for changes in itsvalueattribute instead?I’d suggest listening to
inputandpropertyChangeas this answer suggested:This way when your input value changes (
from any means) you’ll be notified. Edit: does not work if you programatically change the value – for this case, the only cross-browser viable alternative involves polling (for instance this). A better option could be using a framework such as knockout.js, that automates this for you while providing clear separation between view and model. Here’s an example.Update: I recall reading your comment in a deleted answer, stating that you’re programatically setting the value of the input, is that correct? (could some user with 10k rep please restore it?) In that case, why not have the code that is changing the value trigger the listener directly?