Javascript DOM HTML Input Date defaultValue Property get

Introduction

Get the default value of a date field:

var x = document.getElementById("myDate").defaultValue;

Click the button to display the default value of the date field.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="date" id="myDate" value="2020-02-10">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from   www.  j  ava2 s  .c om*/
  var x = document.getElementById("myDate").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related