javascript - How can I trigger an onchange event manually?

Published: 21 June 2023
on channel: Code Samples
222
1

#short
#javascript
#event-handling
#dom-events
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?


Watch video javascript - How can I trigger an onchange event manually? online without registration, duration hours minute second in high quality. This video was added by user Code Samples 21 June 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 222 once and liked it 1 people.