JS simple login verification attached renderings

  • 2020-03-29 23:50:48
  • OfStack

The source code:
 
<!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=gb2312"> 
<meta name="Author" content=" Jiang-bo liu "> 
<script type="text/javascript"> 
function login(){ 
var userName=document.getElementById("userName").value; 
var pwd=document.getElementById("pwd").value; 
var repwd=document.getElementById("repwd").value; 
var address=document.getElementById("address").value; 
var matchResult=true; 
if(userName==""||pwd==""||repwd==""||address==""){ 
alert(" Please confirm if there is any vacancy! "); 
matchResult=false; 
}else if(userName.length<6||userName.length>20){ 
alert(" The username length should be 6 to 20 Between characters! "); 
matchResult=false; 
}else if(userName==pwd||userName==repwd){ 
alert(" Password or duplicate password cannot be the same as username! "); 
matchResult=false; 
}else if(pwd.length<6||pwd.length>20||repwd.length<6||repwd.length>20){ 
alert(" Password or duplicate password length should be in 6 to 20 Between characters! "); 
matchResult=false; 
}else if(pwd!=repwd){ 
alert(" Password and repeat password are different, please re-enter! "); 
matchResult=false; 
}else if(userName.length<6||userName.length>20){ 
alert(" The username length should be 6 to 20 Between characters! "); 
matchResult=false; 
} 

if(matchResult==true){ 
var mailreg = /^w+@w+(.w+)+$/; 
if(!address.match(mailreg)){ 
alert(" Incorrect mailbox format "); 
matchResult=false; 
} 
} 


if(matchResult==true){ 
if(userName.charAt(0)>=0&&userName.charAt(0)<=9){ 
alert(" Username cannot start with a numeric character! "); 
matchResult=false; 
} 
} 

return matchResult; 
} 
</script> 
<title> User registration and verification </title> 
</head> 

<body> 
<center> 
<form name="loginForm" action="http://www.ytu.edu.cn" onsubmit="return login()" method="post"> 
<table bgcolor="#6666FF" width="300" cellspacing="0" cellpadding="0" border="0" align="left" valign="top"> 
<tr> 
<td class="table-title" colspan="2" align="center" bgcolor="#3366FF"> User registration </td> 
</tr> 
<tr> 
<td width="130" height="28" align="left"> Login username </td> 
<td><input id="userName" name="userName" type="text" class="input"></td> 
</tr> 
<tr> 
<td width="80" height="28" align="left"> The login password </td> 
<td><input id="pwd" name="pwd" type="password" class="input"></td> 
</tr> 
<tr> 
<td width="80" height="28" align="left"> Duplicate password </td> 
<td><input id="repwd" name="repwd" type="password" class="input"></td> 
</tr> 
<tr> 
<td width="80" height="28" align="left"> Valid email address </td> 
<td><input id="address" name="address" type="text" class="input"></td> 
</tr> 
<tr> 

<!--<td width="10" height="28" align="left"></td>--> 
<td colspan="2"> 
<input type="submit" value=" The login "> 
<input type="button" value=" cancel " onClick="reset()"></td> 
</tr> 
</table> 
</form> 
</center> 

</body> 
</html> 

Effect realization:
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201311/201311191619256.gif? 20131019161942 ">

Related articles: