//不允许输入中文 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 = webroot+"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; }