Latest web development tutorials

HTML DOM Input Email defaultValue property

Input Email Object Reference Input Email Object

Examples

Modify the default value of the email field:

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

try it"


Definitions and use

defaultValue property sets or returns the default value for the email field.

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

defaultValue and value difference is that the defaultValue attribute contains the default value, value contains the modified value. If you do not modify defaultValue and value are the same (See "More Examples").

defaultValue attribute when you want to see if the email field value changes are very useful.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers are the defaultValue property.

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


grammar

Back defaultValue attributes:

emailObject .defaultValue

Setting defaultValue property:

emailObject .defaultValue = value

Property Value

value description
value It specifies the default value of the email field

technical details

return value: String representing the default value of the email field


More examples

Examples

Gets the default value of the email field:

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

x The output is:


try it"

Examples

This example demonstrates the difference between value and defaultValue attributes:

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

try it"


Input Email Object Reference Input Email Object