标签:
//在字符串中执行查找
function isDisgit(s){
var reg = /^[0-9]{1,20}$/;
var result = reg.exec(s);
//如果格式不正确,返回null ,否则返回 该字符串
alert(result);
}
//执行字符串分割
function splitString(){
var r,reg; //声明变量
reg = /abc/; //创建正则模式
var s = "afdsafdsafdasfasffafafa";
r = s.split(reg); //分割字符串
for(var p in r ){
alert(r[p]);
}
}
//email 验证
function test_email(StrEmail){
var myReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
if(myReg.text(StrEmail)){
return true;
}else{
return false;
}
}
//电话号码验证
function isTel(s){
var patrn = /^(\d{3}-)?\d{8}|(\d{4}-)(\d{7,8})$/;
if(!patrn.text(s){
return false;
}else{
return true;
}
}
//验证手机号码
function isMobil(s){
var patrn = /^1[3,5]\d{9}$/;
if(!patrn.text(s){
return false;
}else{
return true;
}
}
//验证邮编
function idPostalCode(s){
var patrn = /^d{6}$/;
if(!patrn.text(s){
return false;
}else{
return true;
}
}
标签:
原文地址:http://www.cnblogs.com/Xiawu168/p/4759055.html