The most powerful ASP+ajax registration instant prompt program in history is generally used to detect problems before user registration. Friends in need can refer to it. 1. Verify whether the database username exists when registering.
2. When entering the password, you will be prompted for password strength and verify whether the password entered twice is the same.
3. Verify whether the database contact email exists when registering.
4. When registering, verify whether the verification code entered by the user is consistent with the verification code generated by the system.
5. Verify Chinese input
6. QQ number verification
7. ID number verification
Copy the code code as follows:
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
<meta name=copyright content=Copyright 2008-2009 bbmoo.com All Rights Reserved/>
<title>http://www.51weidi.com—Member Registration</title>
<script language=javascript src=regin.js type=text/javascript></script>
<style type=text/css>
.tr,td{
line-height:25px;
font-size:14px;
color: #333;
}
.msg{ color:#FF3300}
.msg2{ color: #006600}
.reg_title{
text-indent:20px;
font-weight:bold;
}
.STYLE1 {color: #FF3300; font-weight:bold;}
</style>
<body>
<form action=reg.asp method=post name=form2>
<table width=100% border=0 cellspacing=1 cellpadding=1>
<tr>
<td colspan=4 class=reg_title>User registration, required information</td>
</tr>
<tr>
<td width=14% align=right>Username:</td>
<td width=12%><input name=u_name id=u_name type=text maxlength=10 onblur=isName() /></td>
<td width=2%><span class=STYLE1 id=name_re>*</span></td>
<td width=72% id=name_re_m>4~10 characters, 2 characters for each Chinese character</td>
</tr>
<tr>
<td align=right>Gender:</td>
<td><input type=radio name=u_sex value=Male/>Male<input type=radio name=u_sex value=Female/>Female<input type=radio name=u_sex value=Shemale/>Shemale</td>
<td><span class=STYLE1 id=sex_re>*</span></td>
<td id=sex_re_m>Look and choose one yourself</td>
</tr>
<tr>
<td align=right>Login password:</td>
<td><input name=u_pass id=u_pass type=password maxlength=12 onblur=password() onkeyup=showStrongPic();/></td>
<td><span class=STYLE1 id=pass_re>*</span></td>
<td><span id=lowPic style=display: ><img src=images/gread_l_x.gif /></span>
<span id=midPic style=display:none><img src=images/gread_m_x.gif /></span>
<span id=highPic style=display:none><img src=images/gread_h_x.gif /></span></td>
</tr>
<tr>
<td align=right>Confirm password:</td>
<td><input name=u_pass_re id=u_pass_re type=password maxlength=12 onblur=pass_re() /></td>
<td><span class=STYLE1 id=pass_re_re>*</span></td>
<td id=pass_re_re_m>Please enter your password again</td>
</tr>
<tr>
<td align=right>Security issues:</td>
<td><select name=u_ask>
<option value=my real name>my real name</option>
<option value=The last 6 digits of my ID card>The last 6 digits of my ID card</option>
<option value=My high school class teacher’s name>My high school class teacher’s name</option>
<option value=My favorite color>My favorite color</option>
<option value=My home zip code number>My home zip code number</option>
</select> </td>
<td><span class=STYLE1>*</span></td>
<td>Choose a familiar question</td>
</tr>
<tr>
<td align=right>Safe answer:</td>
<td><input name=u_answer id=u_answer type=text maxlength=20 onblur=answer() /></td>
<td><span class=STYLE1 id=answer_re>*</span></td>
<td id=answer_re_m>Answer to the above question, used when retrieving password</td>
</tr>
<tr>
<td align=right>Email:</td>
<td><input name=u_mail id=u_mail type=text maxlength=20 onblur=isEmail() /></td>
<td><span class=STYLE1 id=mail_re>*</span></td>
<td id=mail_re_m> Used when retrieving passwords and changing passwords. Please fill them in correctly. Format:[email protected] </td>
</tr>
<tr>
<td align=right>Verification code:</td>
<td><input name=CheckCode type=text id=CheckCode size=4 maxlength=4 onblur=isCheckCode()><img src=Code.asp onclick=this.src = this.src+'?'+Math.random( ); /></td>
<td><span class=STYLE1 id=CheckCode_re>*</span></td>
<td id=CheckCode_re_m>Please enter the correct verification code</td>
</tr>
<tr>
<td colspan=4 class=reg_title>Other information is optional, but it is recommended that you fill it in completely</td>
</tr>
<tr>
<td align=right>Real name:</td>
<td><input name=u_name_zs id=u_name_zs type=text maxlength=4 onblur=name_zs() /></td>
<td><span class=STYLE1 id=name_zs_re></span></td>
<td id=name_zs_re_m>Used when redeeming points, please fill in correctly</td>
</tr>
<tr>
<td align=right><p>Contact QQ: </p> </td>
<td><input name=u_qq id=u_qq type=text maxlength=11 onkeyup=value=value.replace(/[^/d]/g,'') onbeforepaste=clipboardData.setData('text',clipboardData.getData ('text').replace(/[^/d]/g,'')) onblur=qq() /></td>
<td><span class=STYLE1 id=qq_re></span></td>
<td id=qq_re_m>In order to facilitate contact, please fill in correctly</td>
</tr>
<tr>
<td align=right>Alipay number:</td>
<td><input name=u_alipay id=u_alipay type=text maxlength=20 onblur=alipay() /></td>
<td><span class=STYLE1 id=alipay_re></span></td>
<td id=alipay_re_m>Used when redeeming points, please fill it in correctly and make sure the name bound to this number is consistent with the one above</td>
</tr>
<tr>
<td align=right>ID number:</td>
<td><input name=u_nunber id=u_nunber type=text maxlength=18 onkeyup=nunber() /></td>
<td><span class=STYLE1 id=nunber_re></span></td>
<td id=nunber_re_m>Needed to be used in special circumstances, it is recommended to fill in</td>
</tr>
<tr>
<td align=right> </td>
<td align=center><input type=button onclick=tijiao() name=Submit value=Confirm registration/></td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body></html>
regin.js code is as follows
//Create ajax object
var name_re = false;
function name_xml()
{
try {
name_re = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
name_re = new ActiveXObject(Msxml2.XMLHTTP);
} catch (othermicrosoft) {
try {
name_re = new ActiveXObject(Microsoft.XMLHTTP);
} catch (failed) {
name_re = false;
}
}
}
if (!name_re)
alert(Error initializing XMLHttpRequest!);
}
var name_use;
var mail_use;
//ajax password strength verification
function allNumber(v)
{
var reg = /^[0-9]*$/;
if(reg.test(v))
{
return true;
}
return false;
}
function CharMode(iN){
if(iN>=48 && iN<=57)//number
return 1;
if(iN>=65 && iN<=90)//uppercase letters
return 2;
if(iN>=97 && iN<=122)//lowercase
return 4;
else
return 8;//Special characters
}
//Calculate how many modes there are in the current password
function bitTotal(num){
var modes=0;
for(i=0;i<4;i++){
if(num&1)
modes++;
num>>=1;
}
return modes;
}
//Return the password strength level
function checkStrong(sPW){
if(sPW.length<6)
return 0; //Password too short
varModes=0;
for(i=0;i<sPW.length;i++){
//Test the category of each character and count how many patterns there are.
Modes|=CharMode(sPW.charCodeAt(i));
}
// alert(bitTotal(Modes));
return bitTotal(Modes);
}
function showStrongPic()
{
var v = document.getElementById('u_pass').value;
var m = checkStrong(v);
if(m < 2)
{
document.getElementById('lowPic').style.display=;
document.getElementById('midPic').style.display=none;
document.getElementById('highPic').style.display=none;
}
else if(m==2)
{
document.getElementById('lowPic').style.display=none;
document.getElementById('midPic').style.display=;
document.getElementById('highPic').style.display=none;
}
else
{
document.getElementById('lowPic').style.display=none;
document.getElementById('midPic').style.display=none;
document.getElementById('highPic').style.display=;
}
}
//ajax verification code verification
function isCheckCode(){
var CheckCode = document.getElementById('CheckCode').value;
if (CheckCode==){
document.getElementById('CheckCode_re').innerHTML='<img src=check_error.gif>';
document.getElementById('CheckCode_re_m').innerHTML='<span class=msg>The verification code cannot be empty! </span>';
return false;
}else{
Code_ajax(CheckCode)
}
}
function Code_ajax(CheckCode){
var Code=CheckCode;
var url=code_ajax.asp?Code=+ escape(Code);
name_xml();
name_re.open(GET, url, true);
name_re.setRequestHeader(content-type,text/xml);
name_re.onreadystatechange = Code_requst;
name_re.setRequestHeader(If-Modified-Since,0);
name_re.send(null);
}
function Code_requst(){
if(name_re.readyState==4 && name_re.status==200)//Return completed
{
var msg=name_re.responseText;
if (msg==yes){
document.getElementById('CheckCode_re').innerHTML='<img src=check_error.gif>';
document.getElementById('CheckCode_re_m').innerHTML='<span class=msg>Verification code error! </span>';
Code_msg(0);
return false;
}
else{
document.getElementById('CheckCode_re').innerHTML='<img src=check_right.gif>';
document.getElementById('CheckCode_re_m').innerHTML='<span class=msg2>The input is correct! </span>';
Code_msg(1);
return true;
}
}
}
function Code_msg(n){
var n=n;
if(n==0){
Code_use=true;
}
else{
Code_use=false;
}
}
//ajax username verification
function isName(){
var u_name = document.getElementById('u_name').value;
if (u_name==){
document.getElementById('name_re').innerHTML='<img src=check_error.gif>';
document.getElementById('name_re_m').innerHTML='<span class=msg>User name cannot be empty, 4-10 characters</span>';
return false;
}else{
user_ajax(u_name)
}
}
function user_ajax(u_name){
var name=u_name;
var url=ajax.asp?action=names&name=+ escape(name);
name_xml();
name_re.open(GET, url, true);
name_re.setRequestHeader(content-type,text/xml);
name_re.onreadystatechange = name_requst;
name_re.setRequestHeader(If-Modified-Since,0);
name_re.send(null);
}
function name_requst(){
if(name_re.readyState==4 && name_re.status==200)//Return completed
{
var msg=name_re.responseText;
if (msg==yes){
document.getElementById('name_re').innerHTML='<img src=check_error.gif>';
document.getElementById('name_re_m').innerHTML='<span class=msg>The username already exists! </span>';
name_msg(0);
return false;
}
else{
document.getElementById('name_re').innerHTML='<img src=check_right.gif>';
document.getElementById('name_re_m').innerHTML='<span class=msg2>Can be registered! </span>';
name_msg(1);
return true;
}
}
}
function name_msg(n){
var n=n;
if(n==0){
name_use=true;
}
else{
name_use=false;
}
}
//Gender selection detection
function sex(){
if(document.form2.u_sex[0].checked==false && document.form2.u_sex[1].checked==false && document.form2.u_sex[2].checked==false) {
document.getElementById('sex_re').innerHTML='<img src=check_error.gif>';
document.getElementById('sex_re_m').innerHTML='<span class=msg>No gender selected</span>';
return false;
}
else{
document.getElementById('sex_re').innerHTML='<img src=check_right.gif>';
document.getElementById('sex_re_m').innerHTML='<span class=msg2>Selected</span>';
return true;
}
}
//Detect whether the password is empty
function password(){
var u_pass = document.getElementById('u_pass').value;
if(u_pass== || u_pass.length<6){
document.getElementById('pass_re').innerHTML='<img src=check_error.gif>';
return false;
}
else{
document.getElementById('pass_re').innerHTML='<img src=check_right.gif>';
return true;
}
}
//Confirm password detection
function pass_re(){
var u_pass=document.getElementById('u_pass').value;
var pass_re=document.getElementById('u_pass_re').value;
if(u_pass != pass_re){
document.getElementById('pass_re_re').innerHTML='<img src=check_error.gif>';
document.getElementById('pass_re_re_m').innerHTML='<span class=msg>The two passwords are inconsistent, please re-enter</span>';
return false;
}
else{
document.getElementById('pass_re_re').innerHTML='<img src=check_right.gif>';
document.getElementById('pass_re_re_m').innerHTML='<span class=msg2>Fill it in correctly</span>';
return true;
}
}
//Detection of password protection issues
function answer(){
var u_answer=document.getElementById('u_answer').value;
if(u_answer==){
document.getElementById('answer_re').innerHTML='<img src=check_error.gif>';
document.getElementById('answer_re_m').innerHTML='<span class=msg>Please fill in the answer to the question</span>';
return false;
}
else{
document.getElementById('answer_re').innerHTML='<img src=check_right.gif>';
document.getElementById('answer_re_m').innerHTML='<span class=msg2>Fill it in correctly</span>';
return true;
}
}
//Email format verification
function isEmail() {
var u_mail=document.getElementById('u_mail').value;
if (u_mail.search(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0 -9]+)*/.[A-Za-z0-9]+$/) != -1){
email_ajax(u_mail);
}
else{
document.getElementById('mail_re').innerHTML='<img src=check_error.gif>';
document.getElementById('mail_re_m').innerHTML='<span class=msg>Please enter the correct email address in the format: [email protected]</span>';
return false;
}
}
function email_ajax(u_mail){
var email=u_mail;
var url=ajax.asp?action=email&mail=+ escape(email);
name_xml();
name_re.open(GET, url, true);
name_re.setRequestHeader(content-type,text/xml);
name_re.onreadystatechange = mail_requst;
name_re.setRequestHeader(If-Modified-Since,0);
name_re.send(null);
}
function mail_requst(){
if(name_re.readyState==4 && name_re.status==200)//Return completed
{
var msg=name_re.responseText;
if (msg==yes){
document.getElementById('mail_re').innerHTML='<img src=check_error.gif>';
document.getElementById('mail_re_m').innerHTML='<span class=msg>This email address is already in use, please change it</span>';
mail_msg(0);
return false;
}
else{
document.getElementById('mail_re').innerHTML='<img src=check_right.gif>';
document.getElementById('mail_re_m').innerHTML='<span class=msg2>can be used</span>';
mail_msg(1);
return true;
}
}
}
function mail_msg(n){
var n=n;
if(n==0){
mail_use=true;
}
else{
mail_use=false;
}
}
//Real name detection
function name_zs(){
var name_zs=document.getElementById('u_name_zs').value;
if (name_zs != name_zs.replace(/[^/u4E00-/u9FA5]/g,'')|| name_zs== || name_zs.length<2){
document.getElementById('name_zs_re').innerHTML='<img src=check_error.gif>';
document.getElementById('name_zs_re_m').innerHTML='<span class=msg>Please enter your real Chinese name</span>';
return false;
}
else{
document.getElementById('name_zs_re').innerHTML='<img src=check_right.gif>';
document.getElementById('name_zs_re_m').innerHTML='<span class=msg2>Fill it in correctly</span>';
return true;
}
}
//QQ number detection
function qq(){
var qq=document.getElementById('u_qq').value;
if(qq== || qq.length<5){
document.getElementById('qq_re').innerHTML='<img src=check_error.gif>';
document.getElementById('qq_re_m').innerHTML='<span class=msg>The correct QQ is 5-10 digits</span>';
return false;
}
else{
document.getElementById('qq_re').innerHTML='<img src=check_right.gif>';
document.getElementById('qq_re_m').innerHTML='<span class=msg2>Fill it in correctly</span>';
return true;
}
}
//Detect Alipay account
function alipay(){
var alipay=document.getElementById('u_alipay').value;
if (alipay.search(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0 -9]+)*/.[A-Za-z0-9]+$/) != -1){
document.getElementById('alipay_re').innerHTML='<img src=check_right.gif>';
document.getElementById('alipay_re_m').innerHTML='<span class=msg2>Fill it in correctly</span>';
return true;
}
else{
document.getElementById('alipay_re').innerHTML='<img src=check_error.gif>';
document.getElementById('alipay_re_m').innerHTML='<span class=msg>Wrong Alipay account</span>';
return false;
}
}
//ID card number detection
function number(){
var idcard=document.getElementById('u_nunber').value;
var Errors=new Array (verification passed!, ID card number has incorrect digits!, birth date is out of range or contains illegal characters!, ID card number verification error!, ID card area is illegal!);
var area={11:Beijing,12:Tianjin,13:Hebei,14:Shanxi,15:Inner Mongolia,21:Liaoning,22:Jilin,23:Heilongjiang,31:Shanghai,32:Jiangsu,33:Zhejiang,34:Anhui ,35:Fujian,36:Jiangxi,37:Shandong,41:Henan,42:Hubei ,43:Hunan,44:Guangdong,45:Guangxi,46:Hainan,50:Chongqing,51:Sichuan,52:Guizhou,53:Yunnan,54:Tibet,61:Shaanxi,62:Gansu,63:Qinghai,64 :Ningxia, 65: Xinjiang, 71: Taiwan, 81: Hong Kong, 82: Macao, 91: Overseas}
var idcard,Y,JYM;
varS,M;
var idcard_array = new Array();
idcard_array = idcard.split();
if(area[parseInt(idcard.substr(0,2))]==null)
{
document.getElementById('nunber_re').innerHTML='<img src=check_error.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg>+Errors[4]+</span>;
return false;
}
switch(idcard.length){
case 15:
if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard .substr(6,2))+1900) % 4 == 0 )){
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[ 1-2][0-9]|3[0 -1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2] [0-9]))[0-9]{3}$/;
} else {
ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[ 1-2][0-9]|3[0-1 ])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]| 2[0-8]))[0-9]{3}$/;
}
if(ereg.test(idcard)){
document.getElementById('nunber_re').innerHTML='<img src=check_right.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg2>+Errors[0]+</span>;
return true;
}
else {
document.getElementById('nunber_re').innerHTML='<img src=check_error.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg>+Errors[2]+</span>;
return false;
}
break;
case 18:
//18-digit identity number detection
if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))% 4 == 0 )){
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]| [1-2][0-9]|3[0-1] )|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0- 9]))[0-9]{3}[0-9Xx]$/;
} else {
ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]| [1-2][0-9]|3[0-1]) |(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[ 0-8]))[0-9]{3}[0-9Xx]$/;
}
if(ereg.test(idcard)){
S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
+ (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
+ (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
+ (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
+ (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
+ (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
+ (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
+ parseInt(idcard_array[7]) * 1
+ parseInt(idcard_array[8]) * 6
+ parseInt(idcard_array[9]) * 3;
Y = S % 11;
M = F;
JYM = 10X98765432;
M = JYM.substr(Y,1);
if(M == idcard_array[17]){
document.getElementById('nunber_re').innerHTML='<img src=check_right.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg2>+Errors[0]+</span>;
return true;
}
else {
document.getElementById('nunber_re').innerHTML='<img src=check_error.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg>+Errors[3]+</span>;
return false;
}
}
else {
document.getElementById('nunber_re').innerHTML='<img src=check_error.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg>+Errors[2]+</span>;
return false;
}
break;
default:
document.getElementById('nunber_re').innerHTML='<img src=check_error.gif>';
document.getElementById('nunber_re_m').innerHTML=<span class=msg>+Errors[1]+</span>;
return false;
}
}
//Full form submission verification
function tijiao(){
if (isName()==false){
alert(name cannot be empty);
return false;
}
if (name_use==true){
alert(name already exists, re-enter);
return false;
}
if (sex()==false){
alert(please select your gender);
return false;
}
if (password()==false){
alert(password must be filled in);
return false;
}
if (pass_re()==false){
alert(confirm wrong password);
return false;
}
if (answer()==false){
alert (the answer to the security question must be filled in);
return false;
}
if (isEmail()==false){
alert(email address is empty or wrong);
return false;
}
if (mail_use==true){
alert(email already exists, enter a new one);
return false;
}
if(document.getElementById('u_name_zs').value !=){
if(name_zs()==false){
alert(wrong real name);
return false;
}
}
if(document.getElementById('u_qq').value !=){
if(qq()==false){
alert(qq number filled in incorrectly);
return false;
}
}
if (document.getElementById('u_alipay').value !=){
if(alipay()==false){
alert(Alipay account filled in incorrectly);
return false;
}
}
if (document.getElementById('u_nunber').value !=){
if(nunber()==false){
alert(the ID number is incorrectly filled in);
return false;
}
}
document.form2.submit();
return true;
}