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

Javascript examples for DOM HTML Element:Input Datetime

Description

Input Datetime required Property - Set a datetime 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="datetime" id="myDatetime" name="date">
  <input type="submit">
</form>/*from   w ww.  j a  v a 2  s.  c om*/

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

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

<script>
function myFunction() {
    document.getElementById("myDatetime").required = true;
    document.getElementById("demo").innerHTML = "required";
}
</script>
</body>
</html>

Related Tutorials