Home  >  Article  >  Web Front-end  >  Establish a good experience Web registration system ajax_javascript skills

Establish a good experience Web registration system ajax_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:11:181017browse

*项目名称:具有良好体验度的Web注册系统
*作者:草履虫
*联系:caolvchong@gmail.com
*时间:2007-6-29
*起因和版权说明:
  1.蓝色理想上有位会员发布了个类似的系统,提问说验证码不支持firefox的刷新,于是萌生念头做一个.本系统外观(按钮取色等)借鉴了该系统,但细节实现原理并不相同(该文地址:http://bbs.blueidea.com/thread-2761325-1-4.html).
  2.另外,自己做的这个注册系统中利用了网络上的无组件验证码(作者sipo)
  3.至于密码强度的算法借鉴了蓝色理想的一篇文章(http://www.blueidea.com/tech/web/2006/4324.asp),但该算法并不十分理想,如果有更好算法的朋友不妨交流一下
*特点和知识点:
  1.AJAX验证用户名和验证码,同时异步进行用户名注册(都属于AJAX的很基础部分)
  2.支持验证码刷新(包括firefox平台下)
  3.密码,邮箱,用户名等即时检测(利用javascript DOM)
  4.HTML通过W3C Strict验证,CSS也通过W3C CSS验证(其实这个有点多余,并不完全必要)
*开发平台:Windows2003 IIS6.0 Access数据库
*工具:DreamWeaver(写ASP),Aptana(写Javascript,HTML和CSS),Emeditor(写这篇文章),Access2003(数据库)
*测试平台:Firefox2.0,Opera9.21,IE6.0,IE7.0
*演示地址:http://finish.3322.org/reg/reg.htm(短期有效,在本机上,可能访问不顺畅)
*原文地址:http://cceer.xmu.edu.cn/blog/view.asp?id=52
*补充:
  如果你使用这个注册系统,请务必注意下列问题:
    本系统没有对密码进行加密,如果需要,可以搜索MD5加密
    本系统没有进行防注入设置,如果需要,可以搜索SQL防注入
  限于本人水平上的限制,错误和不足在所难免,如果你有问题或者建议,请联系我,感谢!
*这里是效果图
限于文章长度的限制,只帖出两个js文件和一个显示注册页面,至于后台处理页面以及css文件等,请在压缩包中查看
1.reg.htm(由于BLOG会过滤,分开三个部分写) 
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 



草履虫---简易AJAX注册页面
  
  <script></script>
  <script></script>




view plaincopy to clipboardprint?
      
  • 草履虫---Web注册系统   
  •   
          
        支持汉字,单词,数字,敏感字符屏蔽  

  •   
          
        密码在6-16位之间,敏感字符屏蔽  

  •   
          
          

  •   
          
        email是联系重要手段  

  • 验证码:   
          
          

  •   
        相关协议:   
              
                
              

  •   
          
          
          

  • 作者:草履虫   
  • 时间:2007-6-28   
  • 联系:caolvchong@gmail.com   
  • Blog---Web2.0之路:http://cceer.xmu.edu.cn/blog/
    /LI>
                                                                   Supports Chinese characters, words, Numbers, sensitive character masking

                                                                                                                                                                                 🎜> Repeat password:

                                                                                              >
Verification code:

🎜>
Can’t see clearly? Please click on the verification code to refresh

Not accepted

                           

                                                                                                                        :http ://cceer.xmu.edu.cn/blog/






2.detect.js view plaincopy to clipboardprint?
var flag= [0,0,0,0,0,0];
var $=function(tagName){
return document.getElementsByTagName(tagName);
} }
//----- -----Accept the agreement
function accept_info(){
flag[0]=1;
check_data();
} }
//--------- -Rejection of the agreement
function refuse_info(){
flag[0]=0;
check_data();
} }
//----------Reset
function reset_info(){
var info=["Support Chinese characters, words, numbers, sensitive character masking", "Password between 6-16 characters, sensitive character masking","","Email is important for contact Means", "Can't see clearly? Please click the verification code to refresh"]                                                                                              ].innerHTML=info[i];
flag[i]=0;
} }
for(var i=0;i                                                                                                         ​
//---------Email detection
function check_email(email){
var reEmail=/^w ([- .]w )*@w ([-.] w )*.w ([-.]w )*$/;
var b_email=reEmail.test(email);
if(b_email){
$("span")[3]. innerHTML="Establish a good experience Web registration system ajax_javascript skills Email is available";                                                                                   $("span")[3].innerHTML ="
Email error"; 
    flag[1]=0;   
    check_data(); Detection
function check_password(obj){
var pwd=$("input")[1].value; Establish a good experience Web registration system ajax_javascript skills var reChinese=/[u0391-uFFE5] /;
var b_chin ese=reChinese. test(pwd);
var reSpace=/s /;
var b_space=reSpace.test(pwd);
//-------Length test
if(pwd.length $("span")[1].innerHTML="
Password length cannot be less than 6";
flag[2]=0;
check_data();
}                                                                                         Contains Chinese "; "
" " flag[2]=0; " "
" " check_data(); " " else if( b_space){
$("span")[1].innerHTML=" Password cannot contain spaces"; Establish a good experience Web registration system ajax_javascript skills flag[2]=0;
check_data();
}
//-------Display password strength when legal      var  msg=new Array("
Password strength is poor", "
Password strength is average", "
Password strength is strong");
if($("input")[2].value!=""){ Establish a good experience Web registration system ajax_javascript skills check_pw(); Establish a good experience Web registration system ajax_javascript skills return flag[2 ]=1; Establish a good experience Web registration system ajax_javascript skills check_data() ; 
                                                                                           var ls =-1;
                                                                                                       { 
   ls ; 
                                                                       🎜> return ls;
}
//---------Password consistency check
function check_pw(){
var pwd=$("input")[1].value.toString();
var check_pwd=$("input")[2].value.toString();
if(flag[2]==1){
if(pwd==check_pwd){
            $( "span")[2].innerHTML="
Password can be used"; 
 flag[3]=1; 
 check_data(); }
else{
$("span")[2].innerHTML="Establish a good experience Web registration system ajax_javascript skills The two passwords are different";
flag[3]=0;
check_data();
                                                                                                                          Judgment                                                                                                                                                                                                                                       var reId=/^[wu0391-uFFE5]                                                        $("span")[0 ].innerHTML="
Illegal ID name"; else{//Legal username uses ajax’s checkid() Check whether it has been registered                                     check_data() {
if(flag[0]==1 && flag[1]==1 && flag[2]==1 && flag[3]==1 && flag[4]==1 && flag[5] ==1){                                                                                                                put")[8].disabled=true;
                                                                                  --------------------------------

var flag=[0,0,0,0, 0,0];
var $=function(tagName){
return document.getElementsByTagName(tagName);
} Establish a good experience Web registration system ajax_javascript skills //----------Accept the agreement
Function accept_info(){
flag[0]=1;
check_data();
}
//----------Reject protocol
function refuse_info( ){
             flag[0]=0;                                                       
//----------Reset
function reset_info(){
var info=["Support Chinese characters, words, numbers, sensitive character masking", "Password in 6- Between 16 bits, sensitive characters are shielded "," "," email is an important means "," Can't see it clearly? Please click the verification code to refresh "]
for (var I = 0; I                                                                    0 ;i                                                                                                      
//----------Email detection
Function check_email(email){ var reEmail=/^w ([- .]w )*@w ([-.] w )*.w ([-.]w )*$/;
var b_email=reEmail.test(email);
if(b_email){
$("span")[3]. innerHTML="Email is available";
                                                                                                 $("span")[3].innerHTML=" Email Error";
                 flag[1]=0;                        Function check_password (obj){
var pwd=$("input")[1].value;
var reChinese=/[u0391-uFFE5] /;
var b_chinese=reChinese.test(pwd);
var reSpace=/s /;
var b_space=reSpace.test(pwd); >               $("span")[1].innerHTML="Password length cannot be less than 6"; >            //--- ----Legality check: cannot contain Chinese characters
else if(b_chinese){
$("span")[1].innerHTML="Password cannot contain Chinese";
flag[2]= 0;
                       check_data();                     
                                                                                                                                                                                                                                                                                                    
          flag[2]=0; else{
                                                                                         The message prompt var num = getResult (pwd);
varm msg = new array )[1].innerHTML=msg[num];
                                                                                            return flag [2]=1;
                        check_data(); function getResult(s ){
var ls =-1;
if (s.match(/[a-z]/ig)){
ls ;
}
                             if (s.match(/[0 -9]/ig)){
                                                                                                                                      >                                                                                                                             
//---------Password consistency check
function check_pw(){
var pwd=$("input")[1].value.toString();
var check_pwd=$("input")[2].value.toString();
if(flag[2]==1){
if(pwd==_pwd){check
               $( "span")[2].innerHTML="Password can be used";
                                                                                🎜>                                                                                                                                                                                         else{ )[2].innerHTML="Two passwords are not the same";
     flag[3]=0; >                                                                                                                                                                                                . -------- username legality detection
Function Check_id (ID_name) {// can only be letters and numbers. Whether the same uses Ajax to judge
var Reid =/^[wu0391-uffe5] $/ ;
var b_id=reId.test(id_name);
if(!b_id){
> flag[4 ]=0;
check_data();
                                                                                                                                                              >                                                                                                                                                                                                                                                                                       =1 && flag[2]==1 && flag[3]==1 && flag[4]==1 && flag[5]==1){
                                                                               =false;
                                      
                else{
                    $("input")[8].disabled=true;
                }
            }

    //--------------------------------------------------------------------
3.ajax.js view plaincopy to clipboardprint?
function checkcode(regcode){       
    var xmlhttp;   
    try{   
        xmlhttp=new XMLHttpRequest();   
        }   
    catch(e){   
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");   
        }   
    xmlhttp.onreadystatechange=function(){   
    if (xmlhttp.readyState==4){   
        if (xmlhttp.status==200){   
            var data=xmlhttp.responseText;   
            code_result(data);   
            }   
        else{   
            $("span")[4].innerHTML="验证码校验失败,请联系管理员";   
            }   
        }   
    else{   
        $("span")[4].innerHTML="正在进行验证码校验...";   
        }   
    }   
    xmlhttp.open("post", "check_code.asp", true);   
    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');   
    xmlhttp.send("regcode=" escape(regcode));   
}   
function code_result(data){   
    var resultbox=$("span")[4];   
    if(data==1){   
        resultbox.innerHTML='Establish a good experience Web registration system ajax_javascript skills 验证码正确';   
        flag[5]=1;   
        check_data();   
        }   
    else{   
        resultbox.innerHTML='Establish a good experience Web registration system ajax_javascript skills 验证码错误';   
        flag[5]=0;   
        check_data();   
        }   
}   

//--------------------------------------------------------------------   
function checkid(regid){       
    var xmlhttp;   
    try{   
        xmlhttp=new XMLHttpRequest();   
        }   
    catch(e){   
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");   
        }
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4){
if (xmlhttp.status==200){
var data=xmlhttp.responseText; 🎜> id_result(data);                                                                                                                  🎜> else{
$("span")[0].innerHTML="Username verification in progress...";
else{ }
xmlhttp.open("post", "check_id.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send("regid=" escape(regid) );
}
function id_result(data){
var resultbox=$("span")[0];
if(data==1){
resultbox.innerHTML='
Username available';
flag[4]=1;
check_data();
else{
resultbox.innerHTML='
This username has been Register'; 
 flag[4]=0; 
 check_data(); -------------------------------------------------- ---- Establish a good experience Web registration system ajax_javascript skillsfunction sendinfo(regname,pwd,email){
var xmlhttp;
try{ ​​catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp. status==200){
var data=xmlhttp.responseText; Establish a good experience Web registration system ajax_javascript skills reg_result(data);
} }
else{
             $("span")[5].innerHTML="Register Failed, please contact the administrator";
                                      } 
 }
xmlhttp.open("post", "reg.asp", true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp .send("regname=" escape(regname) "&pwd=" escape(pwd) "&email=" escape(email));
}
function reg_result(data){
if(data== 1){
$("span")[5].innerHTML='' $("input")[0].value ",Hello. Please click here to log in";
                                                                                                   Download (including all files, pictures, databases, etc., please test under IIS after decompression)

A registration system with good experience.rar
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn