标题:一个关于ajax注册的问题
取消只看楼主
a309223515
Rank: 2
等 级:论坛游民
帖 子:29
专家分:10
注 册:2010-4-8
结帖率:77.78%
已结贴  问题点数:17 回复次数:2 
一个关于ajax注册的问题
现在程序没有什么大的问题了,但“注册”总是“激活”不了,麻烦有这方面经验的大哥帮看一下,谢谢
// JavaScript Document
function $(id){
    return document.getElementById(id);
}
window.onload = function(){
    $('user_name').focus();
    var user_name1,user_name2,user_pwd1,user_pwd2;
    function chkreg(){
        if((user_name1 == 'yes') && (user_name2 == 'yes') && (user_pwd1 == 'yes') && (user_pwd2 == 'yes')){
            $('regbtn').disabled = false;
        }else{
            $('regbtn').disabled = true;
        }
    }
      

    //验证用户名
    $('user_name').onkeyup = function (){
        name = $('user_name').value;
        user_name2 = '';
        if(name != '' && name.match(/^[a-zA-Z_]*/) == ''){
            $('user_namediv').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=red>必须以字母或下划线开头</font>';
            user_name1 = '';
        }else if(name != '' && name.length < 6){
            $('user_namediv').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=red>注册名称必须大于等于6位</font>';
            user_name1 = '';
        }else if(name == ''){
            $('user_namediv').innerHTML = '';
        }else{
            $('user_namediv').innerHTML = '<img src="images/mak4.png"/>&nbsp;&nbsp;<font color=green>注册名称符合标准</font>';
            user_name1 = 'yes';
        }
        chkreg();
    }


    //验证是否存在该用户
    $('user_name').onblur = function(){
        name = $('user_name').value;
        if(user_name1 == 'yes' && name != ''){
            xmlhttp.open('get','chkname.asp?name='+name,true);
            xmlhttp.onreadystatechange = function(){
                if(xmlhttp.readyState == 4){
                    if(xmlhttp.status == 200){
                        var msg = xmlhttp.responseText;
                        $('user_namediv').innerHTML = msg;
                        if(msg == '2'){
                            $('user_namediv').innerHTML='<img src="images/mak4.png"/>&nbsp;&nbsp;<font color=green>恭喜您,该用户名可以使用!</font>';
                            user_name2 = 'yes';
                        }else if(msg == '1'){
                            $('user_namediv').innerHTML='<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=green>用户名已被占用!</font>';
                            user_name2 = '';
                        }else if(msg == '3'){
                            $('user_namediv').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=green>用户名不能为空!</font>';
                            user_name2= '';
                        }else{
                            $('user_namediv').innerHTML="<font color=red>"+msg+"</font>";
                            user_name2 = '';
                        }
                    }
                }
                chkreg();
            }
            xmlhttp.send(null);
        }
    }
   

    //验证密码
    $('regpwd1').onkeyup = function(){
            pwd = $('regpwd1').value;
            pwd2 = $('regpwd2').value;
        if(pwd == ''){
            $('pwddiv1').innerHTML = '';
            cpwd1 = '';
        }else if(pwd.length < 6 && pwd != ''){
            $('pwddiv1').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=red>密码长度最少需要6位</font>';
            user_pwd1 = '';
        }else if(pwd.length >= 6 && pwd.length < 12){
            $('pwddiv1').innerHTML = '<img src="images/d.png"/>&nbsp;&nbsp;<font color=green>密码符合要求。密码强度:弱</font>';
            user_pwd1 = 'yes';
        }else if((pwd.match(/^[0-9]*$/)!=null) || (pwd.match(/^[a-zA-Z]*$/) != null )){
            $('pwddiv1').innerHTML = '<img src="images/z.png"/>&nbsp;&nbsp;<font color=green>密码符合要求。密码强度:中</font>';
            user_pwd1 = 'yes';
        }else{
            $('pwddiv1').innerHTML = '<img src="images/g.png"/>&nbsp;&nbsp;<font color=green>密码符合要求。密码强度:高</font>';
            user_pwd1 = 'yes';
        }
        if(pwd2 != '' && pwd != pwd2){
            $('pwddiv2').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=red>两次密码不一致!</font>';
            user_pwd2 = '';
        }else if(pwd2 != '' && pwd == pwd2){
            $('pwddiv2').innerHTML = '<img src="images/mak4.png"/>&nbsp;&nbsp;<font color=green>密码输入正确</font>';
            user_pwd2 = 'yes';
        }
        chkreg();
    }
   

   

    //验证确认密码
    $('regpwd2').onkeyup = function(){
        pwd1 = $('regpwd1').value;
        pwd2 = $('regpwd2').value;
        if(pwd1 == '' || pwd2 == ''){
            $('pwddiv2').innerHTML = '';
            regpwd2 = '';
        }else if(pwd1 != pwd2){
            $('pwddiv2').innerHTML = '<img src="images/mak1.png"/>&nbsp;&nbsp;<font color=red>两次密码不一致!</font>';
            regpwd2 = '';
        }else{
            $('pwddiv2').innerHTML = '<img src="images/mak4.png"/>&nbsp;&nbsp;<font color=green>密码输入正确</font>';
            regpwd2 = 'yes';
            chkreg();
        }
    }
    $('morebtn').onclick = function(){
      

        if($('morediv').style.display == ''){
            $('morediv').style.display = 'none';
        }else{
            $('morediv').style.display = '';
        }
    }   

   

    //登录按钮
    $('logbtn').onclick = function(){
        window.open('login.asp','_parent','',false);
    }

   

   

    $('regbtn').onclick = function(){
        $('imgdiv').style.visibility = 'visible';
        url = 'register_chk.asp?name='+$('user_name').value+'&pwd='+$('user_pwd').value;
        url += '&user_guy=' +$('user_guy').value+'&user_city='+$('user_city').value;
        url += '&user_code=' +$('user_code').value+'&user_phone='+$('user_phone').value;
        url += '&user_email='+$('user_email').value+'&Facebook='+$('Facebook').value;
        xmlhttp.open('get',url,true);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4){
                if(xmlhttp.status == 200){
                    msg = xmlhttp.responseText;
                    //alert(msg);
                    $('pwddiv2').innerHTML=msg;
                    if(msg == '1'){
                        alert('注册成功,');
                        location='index.asp';
                    }else{
                        alert(msg);
                    }

                }
            }
        }
        xmlhttp.send(null);
    }
}

搜索更多相关主题的帖子: function false 
2011-03-28 21:14
a309223515
Rank: 2
等 级:论坛游民
帖 子:29
专家分:10
注 册:2010-4-8
得分:0 
大哥,我认为都等于yes
但还是激活不了,你认为呢
还有我感觉这下面的可能有一点问题
    $('regbtn').onclick = function(){
        $('imgdiv').style.visibility = 'visible';
        url = 'register_chk.asp?name='+$('user_name').value+'&pwd='+$('user_pwd').value;
        url += '&user_guy=' +$('user_guy').value+'&user_city='+$('user_city').value;
        url += '&user_code=' +$('user_code').value+'&user_phone='+$('user_phone').value;
        url += '&user_email='+$('user_email').value+'&Facebook='+$('Facebook').value;
        xmlhttp.open('get',url,true);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4){
                if(xmlhttp.status == 200){
                    msg = xmlhttp.responseText;
                    //alert(msg);
                    $('pwddiv2').innerHTML=msg;
                    if(msg == '1'){
                        alert('注册成功,');
                        location='index.asp';
                    }else{
                        alert(msg);
                    }

                }
            }
        }
        xmlhttp.send(null);
    }
2011-03-29 10:24
a309223515
Rank: 2
等 级:论坛游民
帖 子:29
专家分:10
注 册:2010-4-8
得分:0 
回复 2楼 dzt0001
大哥,我认为都等于yes
但还是激活不了,你认为呢
还有我感觉这下面的可能有一点问题
    $('regbtn').onclick = function(){
        $('imgdiv').style.visibility = 'visible';
        url = 'register_chk.asp?name='+$('user_name').value+'&pwd='+$('user_pwd').value;
        url += '&user_guy=' +$('user_guy').value+'&user_city='+$('user_city').value;
        url += '&user_code=' +$('user_code').value+'&user_phone='+$('user_phone').value;
        url += '&user_email='+$('user_email').value+'&Facebook='+$('Facebook').value;
        xmlhttp.open('get',url,true);
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4){
                if(xmlhttp.status == 200){
                    msg = xmlhttp.responseText;
                    //alert(msg);
                    $('pwddiv2').innerHTML=msg;
                    if(msg == '1'){
                        alert('注册成功,');
                        location='index.asp';
                    }else{
                        alert(msg);
                    }

                }
            }
        }
        xmlhttp.send(null);
    }
2011-03-29 10:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-335029-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.113451 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved