我正在尝试使用javascript验证一个html表单,代码如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
function validate(){
if(document.form1.thbox.checked)
{
alert("yes");
}
else
alert("no");
}
</script>
<form name="form1" method="get">
<input type="checkbox" name="thebox"/>
<input type="button" value="press me" onclick="validate()"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我试图按下按钮时没有任何作品有人可以告诉我为什么会这样?谢谢
更改if(document.form1.thbox.checked)到if(document.form1.thebox.checked)你已经错过ê在thebox