<!DOCTYPE html>
<html>
<body>

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

<p>Click the button to set the maximum number of characters allowed in the email field.</p>

<button onclick="myFunction()">Try it</button>

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

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