如何判断两个密码框得值是否相等!

hj12 2003-09-29 05:57:53
写个函数!
...全文
246 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
srj911 2003-09-30
  • 打赏
  • 举报
回复
试试:<input type="submit" value="下一步" name="submit" onclick="return issapce();">
hozi 2003-09-29
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<title>test</title>
<script language="javaScript">
function issapce()
{
if (document.book.password.value=="")
{
alert ("请输入您的密码 !")
document.book.password.focus();
return false
}

if (document.book.password.value.length<4)
{
alert ("您的密码太短了!")
document.book.password.focus();
document.book.password.value="";
document.book.repassword.value="";
return false
}

if (document.book.repassword.value=="")
{
alert ("请输入您的重复密码!")
document.book.repassword.focus();
return false
}

if (document.book.password.value!=document.book.repassword.value)
{
alert ("两次密码不一致 !");
document.book.password.focus();
document.book.password.value="";
document.book.repassword.value="";
return false;
}
return true;
}

function validIfo()
{
if(!issapce()) return false;
}
</script>
</HEAD>
<BODY>
<form action="" name="book" onSubmit="return validIfo()" method="post">
<table width="90%" cellspacing="2" border="0" align="center" cellpadding="3">
<tr>
<td width="128"><font color="#FF0000">*</font>密码:</td>
<td width="262">
<input type="password" size=30 name="password">
</td>
<td width="268">→ 密码至少4位,区分大小写。</td>
</tr>
<tr>
<td width="128"><font color="#FF0000">*</font>重复密码:</td>
<td colspan="2">
<input type="password" size=30 name="repassword">
</td>
</tr>
<tr><td>
<input type="submit" value="下一步>>" name="submit">
</td><td></td></tr>
</table>
</form>
</BODY>
</HTML>
nba23 2003-09-29
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2289/2289198.xml?temp=.1907007
形印声传 2003-09-29
  • 打赏
  • 举报
回复
响应一个事件,如button的onclick事件,或者响应submit事件,另:你的代码不完整,怎么知道你出错在哪里了?
js代码要在<script>和</script>之中!
scycgjr 2003-09-29
  • 打赏
  • 举报
回复
document.theForm.inputUserPassword.value==document.theForm.repassword.value
hj12 2003-09-29
  • 打赏
  • 举报
回复
up
hj12 2003-09-29
  • 打赏
  • 举报
回复
急救!
hj12 2003-09-29
  • 打赏
  • 举报
回复
function repassword(theForm)
{

if(theForm.inputUserPassword.value==theForm.repassword.value)
{

return (true);
}
else
{
alert("两次密码不一致,请重新输入");
theForm.inputUserPassword.value="";
theForm.repassword.value="";
return (false);
}
}
<form name="form1" method="post" action="insert.php" onSubmit="return repassword(form1)">
为什么不执行我得javascript
007james 2003-09-29
  • 打赏
  • 举报
回复
<INPUT id=password1 name=password1 type=password><INPUT id=button1 name=button1 type=button value=Button onclick="if (password1.value==password2.value)alert('密码一样')"><INPUT
id=password2 name=password2 type=password>
形印声传 2003-09-29
  • 打赏
  • 举报
回复
<html>
<body>
<script>
function check()
{
if (p1.value==p2.value){alert('密码相等');}
else alert('密码不等');
}
</script>
<input type=password name=p1><br>
<input type=password name=p2><br>
<input type=button value=检验 onclick=check()>
</body>
</html>

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧