The value
property sets or gets the value attribute of an email field.
value |
Yes | 10.0 | Yes | Yes | Yes |
Return the value property.
var v = emailObject.value
Set the value property.
emailObject.value=text
Value | Description |
---|---|
text | Set a single e-mail address, or a list of e-mail addresses |
A String type value representing a comma-separated list of emails.
The following code shows how to get the email address of an email field.
<!DOCTYPE html>
<html>
<body>
<!--from w w w .ja v a2 s . co m-->
E-mail: <input type="email" id="myEmail" value="abc@example.com">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myEmail").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to change the email address of an email field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w . jav a 2 s . c o m-->
E-mail: <input type="email" id="myEmail" value="aaa@example.com">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myEmail").value = "anc@example.com";
}
</script>
</body>
</html>
The code above is rendered as follows: