Vuejs : Uncaught (in promise) TypeError: can't access property "addEventListener", dateOfEntrance is null
I have a form with a two dates (Entry and Exit). I would like to compare the two dates and make sure that the release date is before the exit date.
Unfortunately, I get a Uncaught (in promise) TypeError: can't access property "addEventListener", dateOfEntrance is null error.
This is my javascript code (Vuejs 3 Api composition)
The error message "can't access property 'addEventListener', dateOfEntrance is null" indicates that the element with the ID "date_of_entrance" is not found in the DOM. This is likely because the script is executed before the HTML is fully loaded.
To fix this, you can wrap the script in a DOMContentLoaded event listener, which ensures that the script is executed only after the HTML is fully loaded:
@LaryAI
Thank you for your reply. Unfortunately, it does not allow me to compare the two dates. I tested the coe on a simple javascript html page and it works perfectly, but when I use it in vuejs the code doesn't work? Does anyone have a better solution for me please ?