81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册界面</title>
<link rel="stylesheet" type="text/css" href="css/register.css">
<script type="text/javascript">
function checkRegisterINfo(form){
/*判断姓名格式是否正确*/
var RegisterNameCheck = document.getElementById("nameId").value;
if(RegisterNameCheck=""){
window.alert("姓名不能为空!");
return false;
}else{
var rightName=/[\u4E00-\u9FA5]{2,16}/;
if(rigntName.test(RegisterNameCheck)==true){
}else{
window.alert("您输入的姓名不正确!");
return false;
}
}
/*判断密码是否规范*/
var RegisterPwdCheck = document.getElementById("pwdId").value;
var rightPwd=/^(\w){6,20}$/;
if(rightPwd.test(RegisterPwdCheck)==false){
window.alert("密码只能输入6-20个字母、数字、下划线");
return false;
}
/*判断密保问题格式是否正确*/
var RegisterQuestionCheck = document.getElementById("questionId").value;
var rightQuestion=/[\u4E00-\u9FA5]{1,16}/;
if(!rightQuestion.test(RegisterQuestionCheck)){
window.alert("密保问题支持1-16位汉字!");
return false;
}
/*判断密保答案格式是否正确*/
var RegisterAnswerCheck = document.getElementById("answerId").value;
var rightAnswer=/[\u4E00-\u9FA5]{1,50}/;
if(!rightAnswer.test(RegisterAnswerCheck)){
window.alert("密保答案支持1-50位汉字!");
return false;
}
}
</script>
</head>
<body>
<div class="main">
<div class="title">
<span>用户注册</span>
</div>
<form name="registerForm" method="post" action="" onsubmit="return checkRegisterINfo(registerForm)">
<!--输入框-->
<div class="input-content">
<div>
<input type="text" autocomplete="off" id="nameId"
placeholder="用户名" name="Registerusername" required/>
</div>
<div style="margin-top: 16px">
<input type="password" autocomplete="off" id="pwdId"
placeholder="登录密码" name="Registerpassword" required maxlength="32"/>
</div>
<div style="margin-top: 16px">
<input type="text" autocomplete="off" id="questionId"
placeholder="密保问题" name="Registerquestion" required maxlength="32"/>
</div>
<div style="margin-top: 16px">
<input type="text" autocomplete="off" id="answerId"
placeholder="密保答案" name="Registeranswer" required maxlength="32"/>
</div>
</div>
<!--登入按钮-->
<div style="margin-top: 105px">
<button type="submit" class="enter-btn" >登录</button>
</div>
<div class="foor">
<div class="left"><span>忘记密码</span></div>
<div class="right"><span>用户登录</span></div>
</div>
</form>
</div>
</body>
</html>
/*判断姓名格式是否正确*/
var RegisterNameCheck = document.getElementById("nameId").value;
if(RegisterNameCheck=""){
……
}else{
……
}