Input Date required Property - Set a date field to be a required part of form submission: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Date

Description

Input Date required Property - Set a date field to be a required part of form submission:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  Date: <input type="date" id="myDate" name="date">
  <input type="submit">
</form>/* w  w  w .jav a 2s. co m*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myDate").required = true;
    document.getElementById("demo").innerHTML = "The date field must now be filled before submitting the form.";
}
</script>

</body>
</html>

Related Tutorials