<html>
<body>
<form action="/demo/htmldom/action_page.php">
复选框:<input type="checkbox" id="myCheck" name="test" required>
<input type="submit">
</form>
<p>单击“试一试”按钮可查看是否必须在提交表单之前选中该复选框。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myCheck").required;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>