Examples of regular verification of mobile phone number, email address, ID card, and bank card

零下一度
Release: 2017-07-03 14:15:15
Original
2997 people have browsed it

手机号码:

var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
Copy after login

电子邮箱:

/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i
Copy after login

身份证:

var isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;var isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
Copy after login

银行卡:

function luhmCheck(bankno){var lastNum=bankno.substr(bankno.length-1,1);//取出最后一位(与luhm进行比较)var first15Num=bankno.substr(0,bankno.length-1);//前15或18位var newArr=new Array();for(var i=first15Num.length-1;i>-1;i--){ //前15或18位倒序存进数组newArr.push(first15Num.substr(i,1)); }var arrJiShu=new Array(); //奇数位*2的积 <9var arrJiShu2=new Array(); //奇数位*2的积 >9var arrOuShu=new Array(); //偶数位数组for(var j=0;j9 的分割之后的数组个位数var jishu_child2=new Array();//奇数位*2 >9 的分割之后的数组十位数for(var h=0;h9 的分割之后的数组个位数之和var sumJiShuChild2=0; //奇数位*2 >9 的分割之后的数组十位数之和var sumTotal=0;for(var m=0;m
         
Copy after login

The above is the detailed content of Examples of regular verification of mobile phone number, email address, ID card, and bank card. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!