Set a date field to be a required of form submission:
document.getElementById("myDate").required = true;
Click button to set the required property for the date field.
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> Date: <input type="date" id="myDate" name="date"> <input type="submit"> </form>/*from w ww.j a va2 s .c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myDate").required = true; document.getElementById("demo").innerHTML = "The required property was set."; } </script> </body> </html>