<html>
<body>
E-mail: <input type="email" id="myEmail">
<p>点击按钮设置 email 字段允许填入的最大字符数。</p>
<p id="demo"></p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction() {
document.getElementById("myEmail").maxLength = "8";
document.getElementById("demo").innerHTML = "email 字段允许填入的最大字符数为 8。";
}
</script>
</body>
</html>