How can I trigger an onchange event manually? [duplicate]

I’m setting a date-time textfield value via a calendar widget. Obviously, the calendar widget does something like this :

document.getElementById('datetimetext').value = date_value;

What I want is:
On changing value in the date-time textfield I need to reset some other fields in the page. I’ve added a onchange event listener to the datetimetext field which is not getting triggered, because I guess onchange gets triggered only when the element gets focus & its value is changed on losing focus.

Hence I’m looking for a way to manually trigger this onchange event (which I guess should take care of checking the value difference in the text field).

Any ideas?

2 s
2

Leave a Comment