Input Email defaultValue Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field


The defaultValue property sets or gets the default value of an email field, which is the value specified in the value attribute.

defaultValue contains the default value, while value contains the current value.

You can use defaultValue property to find out whether the email field have been changed.

Set the defaultValue property with the following Values

Value Description
value Sets the default value of the email field

Return Value

A String, representing the default value of the email field

The following code shows how to change the default value of an email field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

E-mail: <input type="email" id="myEmail" value="">

<button type="button" onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//from  w ww.j  a  v a2s. co  m
    var x = document.getElementById("myEmail");
    x.defaultValue = 'new value';


Related Tutorials