Input Email defaultValueProperty

Input Email 对象参考手册Input Email Object

Example

Change the default value of the email field:

document.getElementById("myEmail").defaultValue = "steve@w3cschool.cc";

Try it yourself »


Definition and Usage

The defaultValue property sets or returns the default value of the email field.

Note:The default value describes the HTMLvalueattribute's value.

defaultValue andvalueThe difference between the properties 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 this defaultValue property.

Note:Internet Explorer 9 and earlier IE versions, and Safari browser do not support the <input type="email"> element.


Syntax

Return the defaultValue property:

emailObject.defaultValue

Set the defaultValue property:

emailObject.defaultValue=value

Property Values

Value Description
value Specifies the default value of the email field

Technical Details

Return value: A 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;

xThe output result is:

johndoe@example.com

Try it yourself »

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 yourself »


Input Email 对象参考手册Input Email Object

Other Extensions