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

Javascript examples for DOM HTML Element:Input Datetime Local

Description

Input DatetimeLocal required Property - Set a local 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-local" id="myLocalDate" name="date">
  <input type="submit">
</form>/*from w ww .  j a  v  a 2s . c o  m*/

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

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

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

Related Tutorials