function exitsid(id) { if(document.getElementById(id)) { return true; } else { return false; } } function clickpw() { $("#pw").hide(); $("#password").show(); $("#password").focus(); } //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 = "可以使用!"; return update_html(id, "1", msg); } else if(data == 2) { msg = "该用户名禁止使用,请重新输入!"; return update_html(id, "0", msg); } else { msg = "用户名已存在!"; return update_html(id, "0", msg); } }); } } if(id == "regpassword") { 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 = $("#regpassword").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 = "手机号码格式错误!"; update_html(id, "0", msg); return false; } 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) { msg = "填写正确!" return 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 + ""); } } } }); } } 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(img) { var username = $.trim($("#username").val()); var realname = $.trim($("#realname").val()); var passconfirm = $.trim($("#passconfirm").val()); var password = $.trim($("#regpassword").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("regpassword"); 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" || $("#regpassword").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 == '' || geetest_validate == '' || geetest_seccode == '') { $("#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(weburl + "/lietou/index.php?c=register", { 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 = weburl + "/index.php?m=register&c=ok&type=1"; } else if(status == 8) { if(code_kind == 1) { checkCode(img); } else if(code_kind >2) { $("#popup-submit").trigger("click"); } layer.msg(msg, 2, 8); } }); } } } $(function() { $(".tips_class").click(function() { if($('#username').attr('date') == '1' || $('#password').attr('date') == '1') { layer.closeTips(); } }); }); //---邮箱获取后缀-- 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 += '