Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Email defaultValue property

Input Email defaultValue property

Input Email Object Reference Input Email Object

Example

Modify the default value of the email field:

document.getElementById(

"myEmail"

).defaultValue =

"steve@w3cschool.cc"

;

Try it »


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 HTML value the value of the property.

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

The defaultValue property is very useful when you want to check whether the email field value has changed.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the defaultValue property.

Note: Internet Explorer 9 and earlier IE versions, as well as the Safari browser, do not support .


Syntax

Return the defaultValue property:

emailObject

.defaultValue

Set the defaultValue property:

emailObject

.defaultValue=

value

Attribute 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 The output result is:

johndoe@example.com

Try it »

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;

Try it »


Input Email Object Reference Input Email Object