jsp提交表单后javascript进行验证,发现验证不通过了,也弹出alert了,但信息依然提交了,求解决方法。 5
<formid="editForm"name="editForm"method="post"action="edit_Judge.jsp"><center><table>...
<form id="editForm" name="editForm" method="post" action="edit_Judge.jsp">
<center>
<table>
<tr>
<td colspan="2">
请输入旧密码:
<input type="password" name="oldPsw"></input>
</td>
</tr>
<tr>
<td colspan="2">
请输入新密码:
<input type="password" name="newPsw"></input>
</td>
</tr>
<tr>
<td colspan="2">
请确认新密码:
<input type="password" name="newPsw2"></input>
</td>
</tr>
<tr>
<td>
<input name="Edit" type="submit" value="确认修改" onclick="return (check())"></input>
</td>
<td>
<input name="eReset" type="reset" value="重置"></input>
</td>
</tr>
</table>
</center>
</form>
js的代码如下
function check(){
if(editForm.oldPsw.value==""){
alert("请输入旧密码!");
editForm.username.focus();
return false;
}
if(editForm.newPsw.value==""){
alert("请输入新密码");
editForm.userpsw.focus();
return false;
}
if(editForm.newPsw2.value!=editForm.newPsw.value){
alert("密码不匹配!");
editForm.userpsw.focus();
return false;
}
}
} 展开
<center>
<table>
<tr>
<td colspan="2">
请输入旧密码:
<input type="password" name="oldPsw"></input>
</td>
</tr>
<tr>
<td colspan="2">
请输入新密码:
<input type="password" name="newPsw"></input>
</td>
</tr>
<tr>
<td colspan="2">
请确认新密码:
<input type="password" name="newPsw2"></input>
</td>
</tr>
<tr>
<td>
<input name="Edit" type="submit" value="确认修改" onclick="return (check())"></input>
</td>
<td>
<input name="eReset" type="reset" value="重置"></input>
</td>
</tr>
</table>
</center>
</form>
js的代码如下
function check(){
if(editForm.oldPsw.value==""){
alert("请输入旧密码!");
editForm.username.focus();
return false;
}
if(editForm.newPsw.value==""){
alert("请输入新密码");
editForm.userpsw.focus();
return false;
}
if(editForm.newPsw2.value!=editForm.newPsw.value){
alert("密码不匹配!");
editForm.userpsw.focus();
return false;
}
}
} 展开
1个回答
展开全部
<input name="Edit" type="submit" value="确认修改" onclick="return (check())"></input>
这句中修改下,改成return check()或者直接改成check()
<form id="editForm" name="editForm" method="post" action="edit_Judge.jsp">
这句中加一个,改成下面这样:
<form id="editForm" onsubmit="return check()" name="editForm" method="post" action="edit_Judge.jsp">
这句中修改下,改成return check()或者直接改成check()
<form id="editForm" name="editForm" method="post" action="edit_Judge.jsp">
这句中加一个,改成下面这样:
<form id="editForm" onsubmit="return check()" name="editForm" method="post" action="edit_Judge.jsp">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询