$(document).ready(function () { site = './'; $("#cpce").html('').hide(); ckaggree(); $("#username").blur(checkuser); $("#realname").blur(checkreal); $("form[name='regform'] input[name='aggree']").change(function () { ckaggree(); }) $("form[name='regform']").submit(function () { var a = checkcp(); var b = checkcpc(); var c = checkpass(); var d = checkuser(); var e = checksex(); var f = checkreal(); var g = checkcode(); if (a && b && c && d && e && f && g) { $(this).ajaxsubmit(function (data) { //alert(data); if (data == 'cpc') { $("#cpce").show().html('手机验证码错误!'); return false; } else if(data == 'failed'){ alert('写入失败!');} else if(data==1){$("#order_form").submit();} else if(data==2){ window.location.reload(); //$("#regbox").fadeout(); // $(".xunjiabox,.box").fadein(); } else { window.location = data; } }); } return false; }); //发送手机验证 $("#sendcode").click(function () { if (checkcp() && checkcode()) { var cellphone = $("#cellphonex").val(); var pcode = $("#pc").val(); $.post(site+'enroll.php', {act: 'click_cnt', cellphone: cellphone , pcode : pcode} , function(data){ //alert(data); if(data == 'code_error'){alert("图片验证码错误!");} else if(data=='cnt_error'){alert("今天您点击次数的太频繁,请明天再来!");} else if(data=='session_error'){alert("操作频繁,请稍后再试!");} else if(data=='yes'){ $.post(site+'enroll.php', {act: 'sendcode', cellphone: cellphone , pcode : pcode }, function(data){ //alert(data); if(data=='session_error'){alert("操作频繁,请稍后再试!");} }); djs(60); } }); } }); //刷新验证码 $("#ref_verify").click(function (){ $("#verify").attr('src',"inc/verify.php?temp="+math.random()); return false; }); //监听验证码输入框 $('#pc').bind('input propertychange', function() { var cl=$(this).val().length; if(cl==4){ checkcode(); } }); if ($(".pwdtd input").val() != '') { $(".pwdtd .colorc").hide(); } $('.inpfoucs').each(function (index, element) { var sv = $(this).val(); $(this).focus(function () { if ($(this).val() == sv) { $(this).val(''); } $(this).css('color', '#333'); }).blur(function () { if ($(this).val() == '' || $(this).val() == sv) { $(this).val(sv).css('color', '#ccc'); } }) }); //密码设置 $(".pwdtd .colorc").click(function () { $(".pwdtd .colorc").hide(); $("#passwordx").focus(); }) $("#passwordx").focus(function () { $(".pwdtd .colorc").hide(); }).blur(function () { var v = $(this).val(); checkpass(); if (v == '') { $(".pwdtd .colorc").show(); } }) }); //倒计时 function djs(n) { n = n - 1; if (n == 0) { $("#sendcode2").hide(); $("#djssecond").hide().html(''); $("#sendcode").show().html('重新发送'); //setcookie('reg_time','0'); } else { $("#sendcode").hide(); $("#sendcode2").css('display', 'block'); $("#sendcode2").html(n + "秒后可重发"); //$("#countdown").html(n); settimeout('djs(' + n + ')', 1000); } } //注册表单递交按钮锁定效果 function ckaggree() { var ag = $("form[name='regform'] input[name='aggree']").is(':checked'); if (ag == false) { $("a.reg-btn").show(); $("input.reg-btn2").hide(); } else if (ag == true) { $("a.reg-btn").hide(); $("input.reg-btn2").show(); } } //检查手机号码 function checkcp() { var cp = $("#cellphonex").val(); if (/^1\d{10}$/.test(cp) && cp != 11111111111) { $.ajax({type: 'post', url: site + 'enroll.php', data: 'act=checkcellphone&cp=' + cp, async: false, success: function (msg) { if (msg == "exist") { $("#cellphonee").show().html('此手机号已被使用!'); $("#ajphone").val('1'); } else { $("#cellphonee").html('').hide(); $("#ajphone").val('0'); } }}); if ($("#ajphone").val() == 1) { return false; } else { return true; } } else { $("#cellphonee").show().html('正确填写手机号码!'); return false; } } //检查手机验证码 function checkcpc() { var cpc = $("#cpc").val(); if (/^\d{6}$/.test(cpc)) { $("#cpce").html('').hide(); return true; } else { $("#cpce").show().html('验证码错误!'); return false; } } //检查密码 function checkpass() { if ($.trim($("#passwordx").val()).length < 6) { $("#passworde").show().html('密码应不少于6位!'); return false; } else { $("#passworde").show().html('').hide(); return true; } } //检查名号 function checkuser() { var txt = $.trim($("#username").val()); if (txt) { if (len(txt) > 14) { $("#usernamee").show().html('您的昵称太长!'); return false; } else { $.post(site + 'enroll.php', {act: 'checkuser', username: txt}, function (data) { if (data == 'illegal') { $("#usernamee").show().html('昵称包含特殊字符!'); $("#ajuser").val('1'); } else if (data == "exist") { $("#usernamee").show().html('昵称已被使用!'); $("#ajuser").val('1'); } else { $("#usernamee").show().html('').hide(); $("#ajuser").val('0'); } }); } if ($("#ajuser").val() == 1) { return false; } else { return true; } } else { $("#usernamee").show().html('请填写您的昵称!'); return false; } } //字符串长度 function len(s) { var x = 0; var a = s.split(""); for (var i = 0; i < a.length; i++) { if (a[i].charcodeat(0) < 299) { x++; } else { x += 2; } } return x; } //检查性别 function checksex() { var v = $("input[name='sex']:checked").val(); if (v > 0) { $("#sexe").html('').hide(); return true; } else { $("#sexe").show().html('请选择性别!'); return false; } } //检查姓名 function checkreal() { var txt = $.trim($("#realname").val()); if (txt) { $("#realnamee").show().hide(''); return true; } else { $("#realnamee").show().html('请填写您的姓名!'); return false; } } //检查图片验证码 function checkcode(){ var txt=$.trim($("#pc").val()); if(txt){ $.post('enroll.php',{act:'checkcode',vercode:txt},function(data){ if(data=='error'){ $("#pce").html("验证码错误!"); $("#pc").focus(); $("#ajcode").val('1'); }else{ $("#pce").html(""); $("#ajcode").val('0'); } }); tmp3v=$("#ajcode").val(); console.log("debug:"+tmp3v); if(tmp3v==1){ return false; }else{ return true; } }else{ $("#pce").html("验证码为空!"); return false; } }