Javascript examples for DOM HTML Element:Input Date
The name property sets or gets the name attribute of a date field.
Set the name property with the following Values
Value | Description |
---|---|
name | Sets the name of the date field |
A String, representing the name of the date field
The following code shows how to get the name of a date field:
<!DOCTYPE html> <html> <body> Birthday: <input type="date" id="myDate" name="bday"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myDate").name; console.log("The name of the date field is: " + x); } function change() {/*w w w . ja va 2 s . com*/ var x = document.getElementById("myDate").name = "newDateName"; console.log("The name was changed to: " + x); } </script> </body> </html>