开发者

Javascript Event Listener on Text Field

I have a text input on a form that I need to check if the value has changed at anytime. Essentially the text input is a date field and I'm using a 3rd parties script to popup a calendar where you can select a date which is then set as the text field value.

So here is my problem. Say when the form is loaded the text field already has a value of 1/1/11 if someone clicks on the field and changes it开发者_开发技巧 with the keyboard to 1/2/11 or anything else my event listener kicks off and executes the function I want. My problem is that if someone clicks the calendar icon and selects a date though it changes the value of the input field it doesn't kick off the event handler.

I've tried using onchange event handler directly on the input box and an event listener for the input box and it appears both only pick up the change when focus on the field has changed. Here is the event listener script the way it sits now..

document.getElementById('anchor1x').addEventListener('change', function() {
   alert("date changed");
}, false);

Is there something else I can do to check if the field value is changed be it by user input through direct typing or through the calendar select?


Perhaps add an event listener to the icon as well? That way when its selected, it'll also fire.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜