<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#smail {
}
</style>
<script>
var ifMail = false;
var ifName = false;
var ifPwd = false;
var ifMPwd = false;
var kong = /s/;
function $$(id) {
return document.getElementById(id);
}
function isMail() {
var mail = $$("mail");
var smail = $$("smail");
if (mail.value.trim().length == 0) {
smail.innerHTML = "邮箱不能为空!!";
}
else {
if (kong.test(mail.value)) {
smail.innerHTML = "输入的邮箱地址中不能有空格!!";
}
else {
var ismail = /^w+@w+.((cn)|(com)|(com.cn))$/;
if (ismail.test(mail.value)) {
ifMail = true;
smail.innerHTML = "√";
smail.style.color = "green";
} else {
smail.innerHTML = "输入的邮箱格式不符合要求!";
}
}
}
}
function isName() {
var name=$$("name");
var sname=$$("sname");
if(name.value.trim().length==0){
sname.innerHTML="昵称不能为空!!";
}else{
if(kong.test(name.value)){
sname.innerHTML="输入的昵称中不能有空格!!";
}else{
var isname=/^[a-zA-Z]+w*/;
if(isname.test(name.value)){
ifName=true;
sname.innerHTML="√";
sname.style.color = "green";
}else{
sname.innerHTML="输入的昵称格式不符合要求!";
}
}
}
}
function isPwd(){
var pwd=$$("pwd");
var spwd=$$("spwd");
if(pwd.value.trim().length==0){
spwd.innerHTML="密码不能为空!!";
}else{
if(kong.test(pwd.value)){
spwd.innerHTML="密码中不能有空格!!";
}else{
if(/[a-zA-z]/.test(pwd.value)&&/d/.test(pwd.value)&&pwd.value.length>=8){
ifPwd=true;
spwd.innerHTML="√";
spwd.style.color = "green";
}else{
spwd.innerHTML="输入的密码过于简单,不符合要求!";
}
}
}
}
function isMpwd(){
var pwd=$$("pwd").value;
var mpwd=$$("mpwd");
var smpwd=$$("smpwd");
if(mpwd.value==pwd){
ifMPwd=true;
smpwd.innerHTML="√";
smpwd.style.color = "green";
}else{
smpwd.innerHTML="两次输入的密码不一致!!";
}
}
function checkAll(){
if(ifMail&&ifName&&ifPwd&&ifMPwd){
return true;
}else{
return false;
}
}
</script>
</head>
<body>
<form name="form1">
Email地址:<input type="text" name="mail" id="mail" onblur="isMail()">
<span id="smail" STYLE="color: red;">*</span></br>
昵称:<input type="text" id="name" onblur="isName()">
<span id="sname" STYLE="color: red;">*</span></br>
设定密码:<input type="password" id="pwd" onblur="isPwd()">
<span id="spwd" STYLE="color: red;">*</span></br>
确定密码:<input type="password" id="mpwd" onblur="isMpwd()">
<span id="smpwd" STYLE="color: red;">*</span></br>
<input type="submit" value="提交注册" onclick="return checkAll()">
</form>
</body>
</html>