Javascript examples for DOM HTML Element:Input Email field
The maxLength property sets or gets the value of the maxlength attribute of an email field, which controls the maximum number of characters allowed in the email field.
To set or return the width of an email field, in number of characters, use the size property.
Set the maxLength property with the following Values
Value | Description |
---|---|
number | Sets the maximum number of characters allowed in the email field. Default value is 524288 |
A Number, representing the maximum number of characters allowed in the email field
The following code shows how to get the maximum number of characters allowed in a specific email field:
<!DOCTYPE html> <html> <body> E-mail: <input type="email" id="myEmail"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from www .java 2 s. c o m*/ var v = document.getElementById("myEmail").maxLength; document.getElementById("demo").innerHTML = v; } </script> </body> </html>