正则表达式

1.判断不能为小数

var regex=/^\d+\.\d+$/;
if(score<1){
alert("不能小于1")
flag1=true;
}else if(regex.test(score)){
alert("不能为小数")
flag1=true;
}

 

正则表达式手册:https://tool.oschina.net/uploads/apidocs/jquery/regexp.html

2.验证邮箱的正则表达式

regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/
 
3.验证手机号的正则表达式
regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
posted @ 2021-09-28 14:15  埃菲尔上的加菲猫  阅读(15)  评论(0编辑  收藏  举报