Easy Tutorial
❮ Prop Style Backgroundclip Jsref Regexp Digit ❯

Input Email defaultValue Property

Input Email Object

Example

Modify the default value of the email field:

document.getElementById("myEmail").defaultValue = "[email protected]";

Definition and Usage

The defaultValue property is used to set or return the default value of the email field.

Note: The default value describes the value of the HTML value attribute.

The difference between defaultValue and value is that defaultValue contains the default value, while value contains the modified value. If no modification is made, defaultValue and value are the same (see "More Examples").

The defaultValue property is useful when you need to check if the value of the email field has changed.


Browser Support

All major browsers support the defaultValue property.

Note: The <input type="email"> element is not supported in Internet Explorer 9 and earlier versions, and Safari.


Syntax

Return the defaultValue property:

Set the defaultValue property:

Property Values

Value Description
value Specifies the default value of the email field

Technical Details

| Return Value: | String, representing the default value of the email field | | --- | --- |


More Examples

Example

Get the default value of the email field:

var x = document.getElementById("myEmail").defaultValue;

x outputs:

[email protected]

Example

This example demonstrates the difference between the defaultValue and value properties:

var x = document.getElementById("myEmail");
var defaultVal = x.defaultValue;
var currentVal = x.value;

Input Email Object

❮ Prop Style Backgroundclip Jsref Regexp Digit ❯