您的位置:首页 > 编程语言 > PHP开发

PHP 实现判断密码两次是否一致

2013-11-04 15:50 525 查看
<?php
header('content-type:text/html; charset=utf-8');	//设置字符集
?>
<!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=UTF-8">
<title>Insert title here</title>
<script>
function on_submit(){
var username=document.getElementById("username");
var pwd=document.getElementById("upassword");
var repwd=document.getElementById("repassword");
if(pwd.value!=repwd.value){
alert("两次密码不一致");
pwd.value="";
repwd.value="";
pwd.focus();
return false;
}
}
</script>
</head>
</head>
<body>
<form action="" method="post" name="form2" id="form2" onsubmit="return on_submit()">
<table width="614" align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">用户名:</td>
<td><input name="username" type="text" value="" size="32"  /></td>
</tr>

<tr valign="baseline">
<td nowrap="nowrap" align="right">密码:</td>
<td><input type="password" id="upassword" size="32"  /></td>
</tr>

<tr valign="baseline">
<td nowrap="nowrap" align="right">重复密码:</td>
<td><input type="password" id="repassword" size="32"  /></td>
</tr>

<tr><td></td><td><input type="submit" value="确定" /></td></tr>
</table>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐