<html>
<body>
<form action="form_action.asp">
E-mail: <input type="email" id="myEmail" name="usremail">
<input type="submit" value="提交">
</form>
<p>点击 "点我" 按钮设置 email 字段为表单的必填部分。</p>
<p><strong>提示:</strong> 在点击 "点我" 按钮前或者后点击 "提交" 按钮查看不同效果。</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myEmail").required = true;
document.getElementById("demo").innerHTML = " required 属性已设置。email 字段为表单的必填项。";
}
</script>
</body>
</html>