I am currently developing a survey website and need assistance with retrieving user input for two specific dates: the start date and end date. I aim to make the survey accessible only between these dates, disabling the "take survey" button after the end date has passed. However, before proceeding to code this functionality, I have encountered an issue trying to display the user's input in the console log. Below is my current setup:
HTML:
<input formControlName="startDate" id="startDate" type="date"/>
TypeScript:
const startDate = document.getElementById('startDate') as HTMLInputElement | null;
console.log(startDate?.value);
Unfortunately, the console.log displays 'undefined'. Any suggestions on how to resolve this issue?
document.querySelector('input').addEventListener('change', () => {
const startDate = document.getElementById('startDate')
console.log(startDate.value);
})
<input formControlName="startDate" id="startDate" type="date" />