Input Email maxLength Property - Set the maximum number of characters allowed in an email field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field

Description

Input Email maxLength Property - Set the maximum number of characters allowed in an email field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

<script>
function myFunction() {/*w  w w.ja va  2 s  .  c om*/
    document.getElementById("myEmail").maxLength = "8";
    document.getElementById("demo").innerHTML = "Maximum number of characters allowed in the email field is now 8.";
}
</script>
</body>
</html>

Related Tutorials