注册 登录
编程论坛 WEB前端(UI)

请问如何判断 两次输入的密码相同???

伟哥 发布于 2006-08-22 14:12, 1967 次点击
在DREAMWERVER中做的网站
如何判断两次密码输入是否相同?
用什么样的语句?
11 回复
#2
hoya2006-08-22 16:29
比较。...

if{a=b} else{}
#3
sunangel2006-08-22 23:19
<title>登录框</title>
<script language="vbscript">
sub button_onClick()
dim uname,upass
uname=document.form1.username.value
upass=document.form1.passwords.value
if(uname="abc" and upass="123")then
msgbox"登录成功"
else
if(uname="")then
msgbox"用户名不能为空"
else
if(uname<>"abc")then
msgbox"用户名错误"
else
if(upass="")then
msgbox"密码不能为空"
else
if(upass<>"123")then
msgbox"密码错误"
end if
end if
end if
end if
end if
end sub
</script>
</head>
<body>
<form name="form1">
用户名:<input name="username" type="text" id="username" value="请输入用户名" onFocus=this.value="" >
密码:<input name="passwords" type="password" id="passwords">
<input type="submit" name="button" value="登录" onClick="button_onClick">
<input type="reset" name="Submits" value="重置">
</form>
</body>
</html>
#4
恋雪2006-09-13 21:46
用msgbox可能有时候会有问题,就是点下去没有反应,问过别人,说是服务器权限的问题,你点击之后,在服务器端会弹出对话框让管理员确认是否允许执行!
#5
风过无影2006-09-14 13:58

也可以这样写;这个写法有很多种

#6
fengmumei2006-09-20 14:39
以下是引用sunangel在2006-8-22 23:19:49的发言:
<title>登录框</title>
<script language="vbscript">
sub button_onClick()
dim uname,upass
uname=document.form1.username.value
upass=document.form1.passwords.value
if(uname="abc" and upass="123")then
msgbox"登录成功"
else
if(uname="")then
msgbox"用户名不能为空"
else
if(uname<>"abc")then
msgbox"用户名错误"
else
if(upass="")then
msgbox"密码不能为空"
else
if(upass<>"123")then
msgbox"密码错误"
end if
end if
end if
end if
end if
end sub
</script>
</head>
<body>
<form name="form1">
用户名:<input name="username" type="text" id="username" value="请输入用户名" onFocus=this.value="" >
密码:<input name="passwords" type="password" id="passwords">
<input type="submit" name="button" value="登录" onClick="button_onClick">
<input type="reset" name="Submits" value="重置">
</form>
</body>
</html>

<form name="form1" onsubmit="return checkdata()">
…………………………………………
</form>
<script>
function checkdata()
{
if (document.form1.username.value=="")
{
alert("用户名不能为空!");
return false;
}
if (document.form1.password.value=="")
{
alert("密码不能为空!");
return false;
}
if (document.form1.repassword.value=="")
{
alert("确认密码不能为空!");
return false;
}
if (document.form1.password.value!=document.form1.repassword.value)
{
alert("密码不一致!");
return false;
}
…………………………
return true;
}
</script>

我的程序中都是这么解决的,不知你的是否合适,自己试试

#7
fengmumei2006-09-20 14:44

虽然我使用的也是dreamweaver,但开发的大都是asp程序,所以不知你的程序是否合适,自己研究研究吧,反正不会差很多的

#8
︷順⑦?zì繎2006-09-20 17:10

还有一个条件!!

一般验证密码时都要先去掉前后的空格

#9
fengmumei2006-09-21 07:43

function checkdata()
{
if (document.form1.username.value=="")
{
window.alert("请输入用户名!")
return false
}
if (document.form1.password.value=="")
{
window.alert("请输入密码!")
return false
}
if (document.form1.repassword.value=="")
{
window.alert("请输入确认密码!")
return false
}
if (document.form1.password.value.length<4)
{
window.alert("你的密码数必须大于4位!")
return false
}
if (document.form1.password.value.length>15)
{
window.alert("您的密码数必须小于15位!")
return false
}
if (document.form1.password.value!=document.form1.repassword.value)
{
window.alert("你的密码不一致!")
return false
}
if (document.form1.answer.value=="")
{
window.alert("请输入您取回密码的答案!")
return false
}
if (document.form1.realname.value=="")
{
window.alert("请输入您的真实姓名!")
return false
}
if (document.form1.phone.value=="")
{
window.alert("请输入您的电话号码!")
return false
}
if (document.form1.zip.value=="")
{
window.alert("请输入您的邮政编码!")
return false
}
if (document.form1.Email.value=="")
{
window.alert("请输入您的邮箱!")
return false
}
if (document.form1.add.value=="")
{
window.alert("请输入您的详细地址!")
return false
}
return true

}

这是我以前用dreamweaver做网站是的一个验证函数,刚找出来,试试看
8楼的说得挺对,最好考虑一下

#10
fjamo22006-09-25 11:32
以下是引用fengmumei在2006-9-20 14:39:58的发言:

<form name="form1" onsubmit="return checkdata()">
…………………………………………
</form>
<script>
function checkdata()
{
if (document.form1.username.value=="")
{
alert("用户名不能为空!");
return false;
}
if (document.form1.password.value=="")
{
alert("密码不能为空!");
return false;
}
if (document.form1.repassword.value=="")
{
alert("确认密码不能为空!");
return false;
}
if (document.form1.password.value!=document.form1.repassword.value)
{
alert("密码不一致!");
return false;
}
…………………………
return true;
}
</script>

我的程序中都是这么解决的,不知你的是否合适,自己试试

我也这么做的

#11
tianykun2006-10-13 10:17
Javascript就行咯...同上楼 嗄 ...
#12
xlmm2006-10-24 21:06
同楼上
1