手机号码,邮箱,身份证号码 正则表达式验证

1、手机验证
var pattern = /0?(13|14|15|17|18)[0-9]{9}/;
var str = "13688888888";
console.log(pattern.test(str));
2、邮箱验证
var pattern = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
var str = "[email protected]";
console.log(pattern.test(str));
3、qq腾讯验证
var pattern = /\d{6}/;
var str = "221000";
console.log(pattern.test(str));
4、身份证号码
var pattern = /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/;
var str = "192.168.225.255";
console.log(pattern.test(str));
5、日期验证
var pattern = /\d{4}(\-|\/|.)\d{1,2}\1\d{1,2}/;
var str = "1988-05-20";
console.log(pattern.test(str));

你可能感兴趣的:(手机号码,邮箱,身份证号码 正则表达式验证)