Javascript DOM HTML Input Date value Property get

Introduction

Get the date of a date field:

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

Click the button to get the date 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   w w w .  j a va 2s.c o  m
  var x = document.getElementById("myDate").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related