$(document).ready(function(){ $('.loginBox input[type="text"]').focus(function(){ $(this).addClass('inputHover') }); $('.loginBox input[type="text"]').blur(function(){ $(this).removeClass('inputHover') }) $('.loginRegBtn li').each(function(){ if($(this).hasClass('active')){ $('#'+$(this).data('id')).show(); } }) //登陆、注册box定位 $('.loginLogo').css('height',$(document).height()/2); // $('.loginReg').css('top',($(window).height()-$('.loginReg').height())/2); //登陆注册切换 $('.loginRegBtn li').click(function(){ if($(this).hasClass('active')){ $('#'+$(this).data('id')).show(); }else{ $('.loginRegBtn li').removeClass('active'); $(this).addClass('active'); $('.loginDiv').hide(); $('#'+$(this).data('id')).show(); } // $('.loginReg').css('top',($(window).height()-$('.loginReg').height())/2); }) //记住账号 $('.remember').click(function(){ if($(this).hasClass('rem_active')){ $(this).removeClass('rem_active') }else{ $(this).addClass('rem_active') } }); $(document).keyup(function(e){ console.log(e) if(e.keyCode == '13'){ $('#loginSubmit').click(); } }) }) //注册blur $("#rPhone").blur(function(event){ event.stopPropagation(); var _this=$(this); var mobileBool; if(_this.val()){ mobileBool = checkMobile(_this.val()); }else{ fnShowErr_New($(this),'手机号码不能为空'); return false; } if(mobileBool){ fnShowErr_New($(this),'请填写正确的手机号码'); return false; } }); $("#rCheckcode").blur(function(event){ event.stopPropagation(); var _this=$(this); if(!_this.val()){ fnShowErr_New($(this),'短信验证码不能为空'); return false; } }); $("#checkcode").blur(function(event){ event.stopPropagation(); var _this=$(this); if(!_this.val()){ fnShowErr_New($(this),'图片验证码不能为空'); return false; } }); $("#rPassword").blur(function(event){ event.stopPropagation(); var _this=$(this); var bBool; if(!_this.val()){ fnShowErr_New($(this),'密码不能为空'); return false; } bBool = _this.val().length<6; if(bBool) { fnShowErr_New($(this),'密码为6-20位字符("`\' # - & 除外)!'); return false; } bBool = _this.val().length>20; if(bBool) { fnShowErr_New($(this),'密码为6-20位字符("`\' # - & 除外)!'); return false; } bBool = checkPwd(_this.val()); if(bBool) { fnShowErr_New($(this),'请检查是否含有特殊字符!'); return false; } }); $("#rePassword").blur(function(event){ event.stopPropagation(); var _this=$(this); var rPassword=$('#rPassword'); var bBool; if(!_this.val()){ fnShowErr_New($(this),'请再次输入密码'); return false; } bBool = _this.val().length<6; if(bBool) { fnShowErr_New($(this),'密码为6-20位字符("`\' # - & 除外)!'); return false; } bBool = _this.val().length>20; if(bBool) { fnShowErr_New($(this),'密码为6-20位字符("`\' # - & 除外)!'); return false; } bBool = _this.val() == rPassword.val(); if(bBool) { fnShowErr_New($(this),'两次输入密码不一致'); return false; } }); //登陆blur $("#lUsername").blur(function(event){ event.stopPropagation(); var _this=$(this); if(!_this.val()){ fnShowErr_New($(this),'手机号或者用户名不能为空'); return false; } }); $("#lPassword").blur(function(event){ event.stopPropagation(); var _this=$(this); if(!_this.val()){ fnShowErr_New($(this),'密码不能为空'); return false; } }); //获取验证码 function get_code(_this){ var time=60;//设置重新获取时间为60秒 var codeBtn=_this; function settime(){ if($("#rPhone").val()){ if(time==0){ codeBtn.removeAttr("disabled"); codeBtn.val("重新获取").css({"color":"#58b7b3","border-color":"#58b7b3"}); return; }else{ codeBtn.attr("disabled","disabled").css({"color":"#bdbdbd","border-color":"#bdbdbd"}); codeBtn.val(""+time+"秒后重试"); time--; } setTimeout(function(){settime()},1000) }else{ fnShowErr($("#rPhone"),'请输入手机号码'); return false; } } settime(); } //错误提示方法 function fnShowErr_New(element, errmsg, positionObj,success_tip_obj){ //去除正确的图标 begin if(success_tip_obj){ success_tip_obj.find('.'+validator.errorTip+',.'+validator.validTip).remove(); }else{ element.parent('*').find('.'+validator.errorTip+',.'+validator.validTip).remove(); } //end var type=element.attr('type'); (type!='checkbox' && type!='radio' && element.addClass(validator['errorinput'])); //element.parent('*').find('.'+this['errorTip']).remove(); element.parent('*').find('.'+validator['validTip']).remove(); $("#"+element.attr('id')+"-msg").remove(); var elementSiblings = element.siblings('.dropselectbox');//用于定位模拟select框 var elementSiblingsFCK = element.siblings('.ke-container');//用于定位rick textarea框 var elementShowPlace = $("#"+element.attr('showplace')); var elementPositionObj; if(positionObj){ elementPositionObj = positionObj; }else{ elementPositionObj = element; } var elementLeft = elementPositionObj.position().left; var elementTop = elementPositionObj.position().top+20; var srcTop = elementTop+elementPositionObj.height(); var nTop = (elementPositionObj.height())/2 - 2 + elementTop; var sHtml = '
'; element.parent().append(sHtml); element.parent().find(".m-layer-msg").show(); element.parent().find(".m-layer-msg").animate({ top: nTop }, "slow", function(){ var _this = $(this); var fnHide = function(){ _this.hide(); } setTimeout(fnHide, 1000); }); $(".errorTip").bgiframe(); } // 下拉选择 $('.search_item').live('click',function(e){ e.stopPropagation(); var $width = $(this).width(); $(this).find('ul').css('width', Math.round($width-2)); // 修复IE7层级问题 if($.browser.msie7){ $(this).css('z-index',50); $('.search_item').not($(this)).css('z-index','auto'); } $('.search_select_list').not($(this).find('.search_select_list')).addClass('hide'); $(this).find('.search_select_list').toggleClass('hide'); $('.search_select_list li').live('click',function(e){ e.stopPropagation(); var $this = $(this); var type = $.trim($this.text()); var _val = $this.data('id'); $this.parent().siblings('input[type="text"]').css({color: "#424242"}); $this.parent().addClass('hide'); if(_val === '') { $this.attr('data-name') && $this.parents('.search_item').find('input[type="text"]').val($this.attr('data-name')).css({color: "#9e9e9e"}) || $this.parents('.search_item').find('input[type="text"]').val(type).css({color: "#9e9e9e"}) ; }else { $this.parents('.search_item').find('input[type="text"]').val(type).attr('title',type); } $this.parents('.search_item').find('.hidden').val(_val); }); $(document).on("click",function(e){ var target = $(e.target); if(target.closest('.search_item').length === 0){ $('.search_item').find('.search_select_list').addClass('hide'); // 修复IE7层级问题 if($.browser.msie7){ $('.search_item').css('z-index','auto'); } } }); $('input.time_input').on('focus',function() { $('.search_item').find('.search_select_list').addClass('hide'); }) }); $('.search_select_list li,.ss_select_list li,.on_list li').live({ mouseenter : function(){ $(this).addClass('active'); }, mouseleave : function(){ $(this).removeClass('active'); } })