//不允许输入中文 var engOnly=function(str){ for(i=0;i2050||m<1||m>12||d<1||d>31) return false; if ((m==4||m==6||m==9||m==11)&&d>30) return false; if ((y%100!=0&&y%4==0)||y%400==0){ if (m==2&&d>29) return false; } else { if (m==2&&d>28) return false; } return true; } //密码强度检测 function passwordGrade(pwd) { var score = 0; var regexArr = ['[0-9]', '[a-z]', '[A-Z]', '[\\W_]']; var repeatCount = 0; var prevChar = ''; //check length var len = pwd.length; score += len > 18 ? 18 : len; //check type for (var i = 0, num = regexArr.length; i < num; i++) { if (eval('/' + regexArr[i] + '/').test(pwd)) score += 4; } //bonus point for (var i = 0, num = regexArr.length; i < num; i++) { if (pwd.match(eval('/' + regexArr[i] + '/g')) && pwd.match(eval('/' + regexArr[i] + '/g')).length >= 2) score += 2; if (pwd.match(eval('/' + regexArr[i] + '/g')) && pwd.match(eval('/' + regexArr[i] + '/g')).length >= 5) score += 2; } //deduction for (var i = 0, num = pwd.length; i < num; i++) { if (pwd.charAt(i) == prevChar) repeatCount++; else prevChar = pwd.charAt(i); } score -= repeatCount * 1; return score; } //字符限制 var charset="gb2312"; function strlen_verify(obj, checklen, maxlen) { var v = obj.value, charlen = 0, maxlen = !maxlen ? 255 : maxlen, curlen = maxlen, len = strlen(v); for(var i = 0; i < v.length; i++) { if(v.charCodeAt(i) < 0 || v.charCodeAt(i) > 255) { curlen -= charset == 'utf-8' ? 2 : 1; } } if(curlen >= len) { $('#'+checklen).html(curlen - len); } else { obj.value = mb_cutstr(v, maxlen, true); } } function mb_cutstr(str, maxlen, dot) { var len = 0; var ret = ''; var dot = !dot ? '...' : ''; maxlen = maxlen - dot.length; for(var i = 0; i < str.length; i++) { len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == 'utf-8' ? 3 : 2) : 1; if(len > maxlen) { ret += dot; break; } ret += str.substr(i, 1); } return ret; } function strlen(str) { return ($.browser.msie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length; } //全选取消 function checkall(form) { for (var i=0;it3){t0=t3} url=t2+t0; if(t4==1){ if(t1!=1){ if(t0<=1){ if(t1==2){t5=t2;} else{t5="./"} }else{ if(t1==2){ var a=t2; var b=a.split("_"); t5=t2+t0+"/"; }else{ t5="index_[page].html" } t5=t5.replace("[page]",t0); } url=t5; } } document.location.href=url; } var cartpath; try{ if (webmode=="2"){ cartpath = webroot+"cart.html"; }else{ cartpath = webroot+"cart.asp"; } }catch(e){cartpath = "/cart.asp";} function get_cartnum(){ if($("#cartnum").length>0){ $.ajax({type:"post",cache:false,url:cartpath+"?act=cartnum",success:function(_){$("#cartnum").html(_);}}); } } function loadtopcart(){ $.ajax({type:"post",cache:false,url:cartpath+"?act=loadtop",success:function(_){$("#cateloading").html(_);}}); } function deltopcart(id){ $.ajax({type:"post",cache:false,url:cartpath+"?act=delcart&id="+id,success:function(_){if(_==1){loadtopcart();get_cartnum();}}}); } function showimg(t0){ top.dialog({ fixed: true, title: '查看图片', align: 'top left', content: '', id: 'picshow' }).showModal(document.getElementById('option-align')); } /* 收藏 */ function addfav(id) { var url, data; url = webroot + "user/ajax.asp"; data = "act=favorite"; data += "&t0=" + encodeURIComponent(id); $.ajax({ type: "post", cache: false, url: url, data: data, success: function(_) { var act = _.substring(0, 1); var info = _.substring(1); switch (act) { case "0": $.fn.tips({type: "error",content: info}); break; case "1": $.fn.tips({type: "error",content: info}); break; case "2": $.fn.tips({type: "ok",content: info}); break; default: alert(_); break } } }); return false } /* 购物车 */ $(function() { $(".is_address").click(function(){$("#address").css("display","block");}); $(".no_address").click(function(){$("#address").css("display","none");}); }); $(function(){ //获取购物车商品数量 get_cartnum(); //清空购物车 if($("#clearcart").length>0){ $("#clearcart").live("click",function(){ if(confirm("确定要清空购物车?")){ $.ajax({ type:"post", cache:false, url:cartpath+"?act=clearcart", success:function(_){ $.fn.tips({type:"ok",content:_}); loadtopcart(); get_cartnum(); if($("#cartlist").length>0){loadcart();} } }); } }) } }) function setqq(qq){ var tempSrc=webroot+'plug/wpa.asp?rantime='+Math.random()+"&qq="+qq; var oldscript=document.getElementById('testJs'); var newscript=document.createElement('script'); newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs'); newscript.setAttribute('src',tempSrc); if(oldscript == null){ document.body.appendChild(newscript);} else{ oldscript.parentNode.replaceChild(newscript, oldscript); } return false; }