电脑做网站空间,广州品牌网站建设公司,详情页设计理念怎么写,企腾网记一次前台验证姓名,手机号,身份证号的代码,复制即用,前提是有引入jquery. var name 姓名if(!is_forbidName(name)){alert(姓名有误!);}var phone 18888888888;var validateTel /^1[23456789]\d{9}/;if(!validateTel.test(phone)){aler…记一次前台验证姓名,手机号,身份证号的代码,复制即用,前提是有引入jquery. var name 姓名if(!is_forbidName(name)){alert(姓名有误!);}var phone 18888888888;var validateTel /^1[23456789]\d{9}/;if(!validateTel.test(phone)){alert(手机号有误!);}var idCard 000000000000000000;if(!regCardNo(idCard )){alert(身份证号有误!);}//姓名校验,正确返回true,不正确返回falsefunction is_forbidName(temp_str) {temp_str temp_str.replace(*, );temp_str temp_str.replace(--, );temp_str temp_str.replace(/, );temp_str temp_str.replace(, );temp_str temp_str.replace(\, );temp_str temp_str.replace(\\, );temp_str temp_str.replace($, );temp_str temp_str.replace(^, );temp_str temp_str.replace(., );temp_str temp_str.replace(;, );temp_str temp_str.replace(, );temp_str temp_str.replace(, );temp_str temp_str.replace(, );temp_str temp_str.replace(, );temp_str temp_str.replace({, );temp_str temp_str.replace(}, );temp_str temp_str.replace(#, );temp_str temp_str.replace(。, );temp_str temp_str.replace(!, );temp_str temp_str.replace(, );temp_str temp_str.replace( , );var forbid_str new String(,%,~,);var forbid_array forbid_str.split(,);for (i 0; i forbid_array.length; i) {if (temp_str.search(new RegExp(forbid_array[i])) ! -1)return false;}return true;}//身份证校验,正确返回true,不正确返回falsefunction regCardNo(idCardNum) {var regBox {regIdCard : /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$///如果通过该验证说明身份证格式正确但准确性还需计算};// idCardNum changeFivteenToEighteen(idCardNum);if(regBox.regIdCard.test(idCardNum)){if(idCardNum.length18){var idCardWinew Array( 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ); //将前17位加权因子保存在数组里var idCardYnew Array( 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ); //这是除以11后可能产生的11位余数、验证码也保存成数组var idCardWiSum0; //用来保存前17位各自乖以加权因子后的总和for(var i0;i17;i){idCardWiSumidCardNum.substring(i,i1)*idCardWi[i];}var idCardModidCardWiSum%11;//计算出校验码所在数组的位置var idCardLastidCardNum.substring(17);//得到最后一位身份证号码//如果等于2则说明校验码是10身份证号码最后一位应该是Xif(idCardMod2){if(idCardLast!X idCardLast!x){return false;}}else{//用计算出的验证码与最后一位身份证号码匹配如果一致说明通过否则是无效的身份证号码if(idCardLast!idCardY[idCardMod]){return false;}}}else{return false;}}else{return false;}return true;}