HTML 登録時に同意書がチェックされているかどうかを確認する

<!DOCTYPE html>
<html lang="en">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>无标题文档</title>
		<script>
			function check(){
	if(!document.getElementById("aaa").checked){
		alert("你必须同意协议");
		return false}
	return true
	}
</script>
	</head>
	<body>
		<form id="form1" name="form1" method="post" action="">
			<div style="border:1px solid #ace;width:800px;height:400px;margin:5px auto;padding:5px">用户协议</div>
			<div style="width:800px;margin:5px auto;text-align:right">
				<p>
					<label>
						<input type="checkbox" name="aaa" id="aaa" />
						我同意</label>
				</p>
				<p>
					<input type="submit" name="button" id="button" value="注册" onclick="return check()" />
				</p>
			</div>
		</form>
	</body>
</html>

 

おすすめ

転載: blog.csdn.net/qq_41255880/article/details/102570566