Input Email size Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field

Description

The size property sets or gets the size attribute of an email field, which controls the width of an email field.

The default value is 20.

Set the size property with the following Values

Value Description
number Sets the width of the email field, in number of characters.

Return Value

A Number, representing the width of the email field, in number of characters

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

<script>
function myFunction() {// w w  w .ja v  a  2s.c o m
    document.getElementById("myEmail").size = 10;
    
}
</script>
</body>
</html>

Related Tutorials