The name
property sets or gets the name attribute of a date field.
The name
attribute from input date field
identifies form data after submitting to the server.
We can also reference form data using JavaScript on the client side.
name |
Yes | No | No | Yes | Yes |
Return the name property.
var v = inputdateObject.name
Set the name property.
inputdateObject.name=name
Value | Description |
---|---|
name | Set the name of the date field |
A String type value representing the name of the date field.
The following code shows how to change the name of a date field.
<!DOCTYPE html>
<html>
<body>
<!--from w ww . j a v a2 s . c o m-->
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 is: " + x);
}
function change() {
var x = document.getElementById("myDate").name = "newDateName";
console.log ("The name was changed to: " + x);
}
</script>
</body>
</html>
The code above is rendered as follows: