Input Email defaultValue attribute
Definition and usage
defaultValue
Sets or returns the default value of the email field.
Note:The default value is HTML value attribute specified in.
The difference between defaultValue and value attributes is:
- defaultValue contains the default value
- While value contains the current value after some changes
- If there is no change, defaultValue and value are the same (see the example below)
The defaultValue attribute is very useful if you want to find out if the email field has been changed.
Instance
Example 1
Change the default value of the email field:
document.getElementById("myEmail").defaultValue = "stevejobs@codew3c.com";
Example 2
Get the default value of the email field:
var x = document.getElementById("myEmail").defaultValue;
Example 3
An example showing the difference between defaultValue and value attributes:
var x = document.getElementById("myEmail"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the defaultValue attribute:
emailObject.defaultValue
Set the defaultValue attribute:
emailObject.defaultValue = value
Attribute Value
Value | Description |
---|---|
value | Specifies the default value of the email field. |
Technical Details
Return Value: | A string value representing the default value of the email field. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |