Javascript DOM HTML Input Date name Property get

Introduction

Get the name of a date field:

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

Click the button to display the value of the name attribute of the date field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Birthday: <input type="date" id="myDate" name="bday">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from  ww  w .  jav  a2s  . c o  m*/
  var x = document.getElementById("myDate").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of a date field.

The name attribute can identify form data after submitting to the server.

Only form elements with a name attribute can transferred to server.

The name property accepts and returns a String type value.




PreviousNext

Related