javascript中onclick事件不响应是怎么回事
<scripttype="text/javascript">functioncheck(){if(form1.user.value==""){alert("请输入用户名!...
<script type="text/javascript">
function check(){
if(form1.user.value==""){
alert("请输入用户名!");
form1.user.focus();
return;
}else if(form1.password.value==""){
alert("请输入密码!");
form1.password.focus();
return;
}else{
form1.submit();
}
</script>
</head>
<body>
<form action="" method="post" name="form1">
<table border="1">
<tr>
<td>用户名:</td>
<td><input type="text" name="user"/></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td><input type="button" value="登录" onClick="check()"></td>
<td><input type="reset" value="重置"></td></tr>
</table>
</form>
</body>
</html> 展开
function check(){
if(form1.user.value==""){
alert("请输入用户名!");
form1.user.focus();
return;
}else if(form1.password.value==""){
alert("请输入密码!");
form1.password.focus();
return;
}else{
form1.submit();
}
</script>
</head>
<body>
<form action="" method="post" name="form1">
<table border="1">
<tr>
<td>用户名:</td>
<td><input type="text" name="user"/></td>
</tr>
<tr>
<td>密 码:</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td><input type="button" value="登录" onClick="check()"></td>
<td><input type="reset" value="重置"></td></tr>
</table>
</form>
</body>
</html> 展开
1个回答
展开全部
<script type="text/javascript">
function check(){
if(form1.user.value==""){
alert("请输入用户名!");
form1.user.focus();
return;
}else if(form1.password.value==""){
alert("请输入密码!");
form1.password.focus();
return;
}else{
form1.submit();
}
}
</script>
最后少了一个大括号}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询