Javascript DOM HTML Input DatetimeLocal defaultValue Property get

Introduction

Get the default value of a datetime field:

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

Click the button to get the default value of the datetime field.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime-local" id="myLocalDate" value="2014-11-16T15:25:33">

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

<script>
function myFunction() {/*ww  w  . j  a v  a2s . co m*/
  var x = document.getElementById("myLocalDate").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related