The size
property sets or gets the size attribute of an email field.
The size
attribute from input email field
specifies the width of an email field in number of characters. The default value is 20.
size |
Yes | 10.0 | Yes | Yes | Yes |
Return the size property.
var v = emailObject.size
Set the size property.
emailObject.size=number
Value | Description |
---|---|
number | Set the width of the email field, in number of characters. Default value is 20 |
A Number type value representing the width of the email field, in number of characters.
The following code shows how to get the width of an email field in number of characters.
<!DOCTYPE html>
<html>
<body>
<!--from w w w .ja va 2 s . c o m-->
E-mail: <input type="email" id="myEmail" size="30">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myEmail").size;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to change the width of an email field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w. j a v a 2 s . c o m-->
E-mail: <input type="email" id="myEmail">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
document.getElementById("myEmail").size = "50";
}
</script>
</body>
</html>
The code above is rendered as follows: