Get the name of a datetime field:
var x = document.getElementById("myDatetime").name;
Click the button to display the value of the name attribute of the datetime field.
<!DOCTYPE html> <html> <body> Birthday: <input type="datetime" id="myDatetime" name="bdaytime"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w ww . j a v a 2s. c o m*/ var x = document.getElementById("myDatetime").name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The name
property sets or gets the value of the name attribute of a datetime field.
The name attribute can identify form data after submitting to the server.
Only form elements with a name attribute will get submitted to the server.
The name
property accepts and returns a String type Value.