Javascript DOM HTML Input Date type Property get

Introduction

Return which type of form element the date field is:

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

Click the button to return which type of form element the date field is.

View in separate window

<!DOCTYPE html>
<html>
<body>

A date control: <input type="date" id="myDate">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*  w w w  . j av  a  2s .co m*/
  var x = document.getElementById("myDate").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element the date field is.

It returns a string type value.




PreviousNext

Related