Date function Example

Use Javascript date function for form validation

  // Get the current date 
    const today = new Date(); 
     
    // Format the date to YYYY-MM-DD 
    const formattedDate = today.toISOString().split('T')[0]; 

    // Set the value of the date input to the current date 
    document.getElementById('date').value = formattedDate;