简单的javascript判断密码是否正确

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
table {
margin:20px auto;
border: 2px solid orange;
}
td{
width: 200px;
height: 40px;
text-align: right;
color:black;
background: #aa9988;
padding: 5px;
font-size: 24px;
line-height: 40px;
}
select,input {
width: 200px;
height: 40px;
text-align: left;
}
.sex{
width: 30px;
height: 30px;
font-size: 12px;
text-align: left;
}
#st5,#st6{
text-align: left;
}
#st7,#st8{
height: 30px;
border-radius: 15px; 
font-size: 20px;
text-align: center;
}
</style>
<script type="text/javascript">
function $e(ele){
return document.getElementById(ele);
}
function check(){
var boo=$e("st3").value==$e("st4").value;
if(boo){
return true;
}else{
alert("密码不正确");
}
}
function cs(){
var str='';
str +="\n用户名: ";
str +=$e('st1').value;
str +="\n联系电话: ";
str +=$e('st2').value;
str +="\n性别: ";
str +=$e('st5').checked ? '男':'女';
str +="\n学历: "
str +=$e('select').value;
alert("用户信息:\n"+str);
}
</script>
</head>
<body>
<table>
<tr>
<td>用户名</td>
<td><input type="text" id="st1"></td>
</tr>
<tr>
<td>联系电话</td>
<td><input type="text" id="st2"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" id="st3"></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="password" id="st4" οnblur="check()"></td>
</tr>
<tr>
<td>性别</td>
<td>男<input type="radio" id="st5" class="sex" name="sex">女<input type="radio" id="st6" class="sex" name="sex"></td>
</tr>
<tr>
<td>学历</td>
<td><select id='select'><option>初中</option><option>高中</option>
<option>本科</option><option>专科</option></select></td>
</tr>
<tr><td colspan="2"><input id="st7" type="submit" value="提交" οnclick="cs()"><input id="st8" type="reset" value="重置"></td></tr>
</table>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值