关于密码判断的小问题,大家看看哪个地方有错误
在输入密码时,“密码”和“确认密码”不管相不相同,都提示“考生的密码两次输入不一致!”,大家看一下是哪个地方的毛病,代码如下:
<!--#include file= "NS_Conn.asp "-->
<!--#include file= "NS_Exam_checkuser.asp "-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 在线考试管理系统 </title>
<style type= "text/css ">
<!--
body {
background-color: #EFF8FE;
}
body,td,th {
font-size: 12px;
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style>
<script language= "javascript ">
function checkform(myform)
{
if(myform.zkz.value== " ")
{
alert( "考生的准考证号不能为空! ");
myform.zkz.focus();
return false;
}
if(myform.psw.value== " ")
{
alert( "考生的密码不能为空! ");
myform.psw.focus();
return false;
}
if(myform.psw1.value== " ")
{
alert( "确认密码不能为空! ");
myform.psw1.focus();
return false;
}
if(myform.psw.value!=myform.psw1.value);
{
alert( "考生的密码两次输入不一致! "+myform.psw.value+ "\n "+myform.psw1.value);
myform.psw.focus();
return false;
}
if(myform.name.value== " ")
{
alert( "考生的真实姓名不能为空! ");
myform.name.focus();
return false;
}
}
</script>
</head>
<body>
<form action= "NS_Exam_kaosheng_add.asp " method= "post " name= "cnwy " id= "cnwy " onsubmit= "return checkform(this) ">
<table width= "347 " align= "center " cellpadding= "1 " cellspacing= "1 " bgcolor= "#67B0ED ">
<tr>
<td colspan= "2 " bgcolor= "#EFF8FE "> <div align= "center "> 考生增加 </div> </td>
</tr>
<tr>
<td width= "116 " bgcolor= "#EFF8FE "> 考生的准考证号: </td>
<td width= "222 " bgcolor= "#EFF8FE "> <input name= "zkz " type= "text " id= "zkz " size= "16 "> </td>
</tr>
<tr>
<td bgcolor= "#EFF8FE "> 考生登陆的密码: </td>
<td bgcolor= "#EFF8FE "> <input name= "psw " type= "password " id= "psw " size= "16 " maxlength= "16 "> </td>
</tr>
<tr>
<td bgcolor= "#EFF8FE "> 确认考生的密码: </td>
<td bgcolor= "#EFF8FE "> <input name= "psw1 " type= "password " id= "psw1 " size= "16 " maxlength= "16 "> </td>
</tr>
<tr>
<td bgcolor= "#EFF8FE "> 考生的真实姓名: </td>
<td bgcolor= "#EFF8FE "> <input name= "name " type= "text " id= "name " size= "16 "> </td>
</tr>
<tr>
<td bgcolor= "#EFF8FE "> 考生所在的班级: </td>
<td bgcolor= "#EFF8FE "> <select name= "class " id= "class ">
<%dim rs,sql
set rs=server.createobject( "adodb.recordset ")
sql= "select * from class order by id desc "
rs.open sql,conn,1,1
if not rs.eof then
rs.movefirst
do while not rs.eof
%>
<option value= " <%=rs( "class ")%> "> <%=rs( "class ")%> </option>
<%rs.movenext
loop
else
%>
<option value= "暂时没有任何数据 "> 暂时没有任何数据 </option>
<%end if
rs.close
set rs=nothing
set conn=nothing%>
</select> </td>
</tr>
<tr>
<td bgcolor= "#EFF8FE "> 考生所在的学校: </td>
<td bgcolor= "#EFF8FE "> <input name= "school " type= "text " id= "school " size= "16 " > </td>
</tr>
<tr>
<td colspan= "2 " bgcolor= "#EFF8FE "> <table width= "171 " border= "0 " align= "center ">
<tr>
<td width= "78 "> <input name= "Submit " type= "submit " value= "添加 "> </td>
<td width= "83 "> <input type= "reset " name= "Submit2 " value= "清除 "> </td>
</tr>
</table> </td>
</tr>
</table>
</form>
</body>
</html>
[解决办法]
楼主最好用document。
我以前也遇到。改了就行了。
[解决办法]
在前面都要加上Document.
例如:
Document.myform.zkz.value== " "
[解决办法]
不是Document,是document,看得出来LZ把两个值都输出来看过(在对话框中),相信看到的是一样的吧?如果真的这样,可以再加个document试试,如果还不行,可以return checkform( 'cnwy ')改成这个看看。
[解决办法]
if(myform.psw.value!=myform.psw1.value); 把;号去掉却可.
[解决办法]
if ()后不要跟;号 ;号代表语句结束.
因此等于永远会执行以下语句:
{
alert( "考生的密码两次输入不一致! "+myform.psw.value+ "\n "+myform.psw1.value);
myform.psw.focus();
return false;
}
[解决办法]
楼上的正解啊!