function exitsid(id){ if(document.getElementById(id)){ return true; }else{ return false; } } //JS -- 登录注册 function reg_checkAjax(id){ var obj = $("#"+id).val(); var msg; if(id=="username"){ if(obj==""){ msg='用户名不能为空!'; update_html(id,"0",msg); return false; }else if(obj.length<2||obj.length>16){ msg = "用户名应该在2-16个字符!"; return update_html(id,"0",msg); }else{ $.post(weburl+"/index.php?m=register&c=ajaxreg",{username:obj},function(data){ if(data==0){ msg='填写正确!'; update_html(id,"1",msg); }else{ if(data==1){ msg="用户名已存在!"; }else if(data==2){ msg="用户名不得包含特殊字符!"; }else if(data==3){ msg="该用户名已被禁止注册!"; } update_html(id,"0",msg); } }); } } if(id=="password"){ if(obj==""){ msg='密码不能为空!'; update_html(id,"0",msg); return false; }else if(obj.length<6 || obj.length>20){ msg = "密码应该在6-20个字符!"; return update_html(id,"0",msg); }else{ msg = "填写正确!"; return update_html(id,"1",msg); } } if(id=="passconfirm"){ var obj2 = $("#password").val(); if(obj==""){ msg = "重复密码不能为空!"; return update_html(id,"0",msg); }else if(obj2!=obj){ msg = "重复密码不一致!"; return update_html(id,"0",msg); }else{ msg = "填写正确!"; return update_html(id,"1",msg); } } if(id=="moblie"){ if(obj==''){ msg="手机号不能为空!"; update_html(id,"0",msg); return false; }else if(!isjsMobile(obj)){ msg = "手机格式不正确!" return update_html(id,"0",msg); }else{ $.post(weburl+"/index.php?m=register&c=regmoblie",{moblie:obj},function(data){ if(data==0){ msg='填写正确!'; update_html(id,"1",msg); return true; }else{ if(data == 2) { msg = "该手机号已被禁止使用!"; update_html(id, "0", msg); } else { if(document.getElementById('written_off').style.display!='none'){ return; } var data = eval('(' + data + ')'); var msglayer = layer.open({ type: 1, title: '手机号已被占用', closeBtn: 1, border: [10, 0.3, '#000', true], area: ['550px', 'auto'], content: $("#written_off"), cancel: function() { window.location.reload(); } }); $("#moblie").val(""); $("#zy_uid").val(data.uid); $("#zy_mobile").val(obj); if(data.usertype == '1') { $("#zy_type").html("该手机号已被注册为个人账号"); if(data.name){ $("#zy_name").html("个人名称:" + data.name.substr(0, 1) + "**"); } } else if(data.usertype == '2') { $("#zy_type").html("该手机号已被注册为企业账号"); if(data.name){ $("#zy_name").html("企业名称:" + data.name + ""); } } else if(data.usertype == '3') { $("#zy_type").html("该手机号已被注册为猎头账号"); if(data.name){ $("#zy_name").html("猎头姓名:" + data.name.substr(0, 1) + "**"); } } else if(data.usertype == '4') { $("#zy_type").html("该手机号已被注册为培训账号"); if(data.name){ $("#zy_name").html("机构名称:" + data.name + ""); } } } } }); } } if(id=="email1"){ //对电子邮件的验证 var myreg = /^([a-zA-Z0-9\-]+[_|\_|\.]?)*[a-zA-Z0-9\-]+@([a-zA-Z0-9\-]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; if(obj==""){ msg='邮箱不能为空!'; update_html(id,"0",msg); return false; }else if(!myreg.test(obj)){ msg = "邮箱格式不正确!" return update_html(id,"0",msg); }else{ $.post(weburl+"/index.php?m=register&c=regemail",{email:obj},function(data){ if(data==0){ $("#def"+id).hide(); msg="输入成功!"; update_html(id,"1",msg); }else{ if(document.getElementById('written_off').style.display!='none'){ return; } var data = eval('(' + data + ')'); var msglayer = layer.open({ type: 1, title: '邮箱已被占用', closeBtn: 1, border: [10, 0.3, '#000', true], area: ['550px', 'auto'], content: $("#written_off"), cancel: function() { window.location.reload(); } }); $("#email").val(""); $("#zy_uid").val(data.uid); $("#zy_email").val(obj); $("#desc_toast").html("2. 解除邮箱与该账号的绑定,解除绑定后,您无法继续用该邮箱登录"); if(data.usertype == '1') { $("#zy_type").html("该邮箱已被注册为个人账号"); if(data.name){ $("#zy_name").html("个人名称:" + data.name.substr(0, 1) + "**"); } } else if(data.usertype == '2') { $("#zy_type").html("该邮箱已被注册为企业账号"); if(data.name){ $("#zy_name").html("企业名称:" + data.name + ""); } } else if(data.usertype == '3') { $("#zy_type").html("该邮箱已被注册为猎头账号"); if(data.name){ $("#zy_name").html("猎头姓名:" + data.name.substr(0, 1) + "**"); } } else if(data.usertype == '4') { $("#zy_type").html("该邮箱已被注册为培训账号"); if(data.name){ $("#zy_name").html("机构名称:" + data.name + ""); } } // msg = "邮箱已存在!" // return update_html(id,"0",msg); } }); } } if(id=="CheckCode"){ if(obj==""){ msg="请输入验证码!"; update_html(id,"0",msg); }else{ msg="输入成功!"; update_html(id,"1",msg); } } if(id == "moblie_code"){ if(obj==""){ msg="请输入短信验证码!"; update_html(id,"0",msg); }else{ msg="输入成功!"; update_html(id,"1",msg); } } if(id=="realname"){ var rname = /^[\u4e00-\u9fa5]+(·[\u4e00-\u9fa5]+)*$/; if(obj==""){ msg='真实姓名不能为空!'; update_html(id,"0",msg); return false; }else if(obj.length<2){ msg = "真实姓名应该多于1个字符!"; return update_html(id,"0",msg); }else if(!rname.test(obj)){ msg = "真实姓名格式不规范!" return update_html(id,"0",msg); }else{ $.post(weburl+"/index.php?m=register&c=ajaxreg",{realname:obj},function(data){ if(data==0){ msg = "可以使用!"; return update_html(id,"1",msg); }else{ msg = "请输入真实姓名!"; return update_html(id,"0",msg); } }); } } } function update_html(id,type,msg){ if(type=="1"){ $("#ajax_"+id).html(''+msg); $("#ajax_"+id).attr('class','reg_tips reg_tips_blue false'); }else{ $("#ajax_"+id).html(''+msg); $("#ajax_"+id).attr('class','reg_tips reg_tips_red false'); } $("#ajax_"+id).show(); $("#"+id).attr('date',type); } function checkform(url,okurl,img){ var username=$.trim($("#username").val()); var realname=$.trim($("#realname").val()); var passconfirm=$.trim($("#passconfirm").val()); var password=$.trim($("#password").val()); var email1=$.trim($("#email1").val()); var moblie=$.trim($("#moblie").val()); var authcode=$.trim($("#CheckCode").val()); var verify_token; var moblie_code; reg_checkAjax("username"); reg_checkAjax("password"); reg_checkAjax("passconfirm"); reg_checkAjax("moblie"); reg_checkAjax("email1"); if(exitsid("CheckCode")){ reg_checkAjax("CheckCode"); } if(exitsid("moblie_code")){ reg_checkAjax("moblie_code"); } if(exitsid("realname")){ reg_checkAjax("realname"); } if($("#username").attr('date')!="1"||$("#password").attr('date')!="1"||$("#passconfirm").attr('date')!="1"||$("#email1").attr('date')!="1"||$("#moblie").attr('date')!="1"|| (exitsid("realname") && $("#realname").attr('date')!="1")){ return false; }else{ var codesear=new RegExp('注册会员'); if(codesear.test(code_web)){ if(code_kind==1){ reg_checkAjax("CheckCode"); if($("#CheckCode").attr('date')!="1"){ return false; } }else if(code_kind > 2){ verify_token = $('input[name="verify_token"]').val(); if(verify_token ==''){ $("#bind-submit").trigger("click"); return false; } } } if($("#xieyi").attr("checked")!='checked'){ layer.msg('您必须同意注册协议才能成为本站会员!', 2, 8);return false; }else{ if(exitsid("moblie_code")){ reg_checkAjax("moblie_code"); moblie_code = $.trim($("#moblie_code").val()); } var loadi = layer.load('正在注册……',0); $.post(url,{ username:username, realname:realname, password:password, passconfirm:passconfirm, email:email1, moblie:moblie, moblie_code:moblie_code, authcode:authcode, verify_token:verify_token },function(data){ layer.close(loadi); var data=eval('('+data+')'); var status=data.status; var msg=data.msg; if(status==1){ window.location.href=weburl+"/member/index.php"; }else if(status==0){ window.location.href =okurl; }else if(status==8){ if(codesear.test(code_web)){ if(code_kind==1){ checkCode(img); }else if(code_kind>2){ $("#popup-submit").trigger("click"); } } layer.msg(msg, 2, 8); } }); } } } function checklogin(url,img){ var username=$("#username").val(); var backurl=$("#referurl").val(); var password=$("#password").val(); var authcode=$("#txt_CheckCode").val(); var cookie=$("#cookie").val(); var verify_token; if(username==""){ layer.msg('用户名不能为空!', 2, 8);return false; } if(password==''){ layer.msg('密码不能为空!', 2, 8);return false; } var codesear=new RegExp('前台登录'); if(codesear.test(code_web)){ if(code_kind==1){ if(authcode==""){ layer.msg('验证码不能为空!', 2,8);return false; } }else if(code_kind > 2){ verify_token = $('input[name="verify_token"]').val(); if(verify_token ==''){ $("#bind-submit").trigger("click"); return false; } } } loadlayer(); $.post(url,{ username:username, password:password, backurl:backurl, authcode:authcode, verify_token:verify_token },function(data){ layer.closeAll('loading'); var data = eval('(' + data + ')'); if(data.errcode==1){ window.location.href=data.url; }else if(data==2){ window.location.href=weburl+"/index.php?m=register&c=ok&type=2"; }else if(data==3){ window.location.href=weburl+"/index.php?m=register&c=ok&type=3"; }else if(data==5){ window.location.href=weburl+"/index.php?m=register&c=ok&type=5"; }else{ if(codesear.test(code_web)){ if(code_kind==1){ checkCode(img); }else if(code_kind>2){ $("#popup-submit").trigger("click"); } } layer.msg(data, 2, 8); } }) } //---邮箱获取后缀-- function get_def_email(email,type){ $("#ajax_email"+type).hide(); var postemail=email.split("@"); var configemail = $('#defEmail').val(); var def_email=configemail.split("|"); var emails=[]; if($.trim(postemail[1])!=""){ $.each(def_email,function(index,data){ if(data.indexOf(postemail[1])>-1){ emails.push(data); }; }); }else{ emails=def_email; } var html=''; $.each(emails,function(index,data){ if(index==0){ $class=" reg_email_box_list_hover"; }else{ $class=""; } html+='