正则匹配
来源:互联网 发布:机械 simulink 知乎 编辑:程序博客网 时间:2024/06/05 04:55
//手机正则开始
function checkPhone(){
var sPhone = document.getElementById("tel").value;
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sPhone))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("手机号");//这个是公共弹出框的文字
document.getElementById("tel").value='';
return false;
}
}
//手机正则结束
//身份证正则开始
function checkCard(){
var idCard=document.getElementById("idCard").value;
if(!(/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test(idCard))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("身份证");//这个是公共弹出框的文字
document.getElementById("idCard").value='';
return false;
}
}
//身份证正则结束
//姓名禁止输入特殊字符开始 /[@#\$%\^&\*]+/g
function checkName(){
var idName=document.getElementById("name").value;
if(!(/^[\u4e00-\u9fa5a-z]+$/gi.test(idName))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("姓名");//这个是公共弹出框的文字
document.getElementById("name").value='';
return false;
}
}
function checkPhone(){
var sPhone = document.getElementById("tel").value;
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sPhone))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("手机号");//这个是公共弹出框的文字
document.getElementById("tel").value='';
return false;
}
}
//手机正则结束
//身份证正则开始
function checkCard(){
var idCard=document.getElementById("idCard").value;
if(!(/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/.test(idCard))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("身份证");//这个是公共弹出框的文字
document.getElementById("idCard").value='';
return false;
}
}
//身份证正则结束
//姓名禁止输入特殊字符开始 /[@#\$%\^&\*]+/g
function checkName(){
var idName=document.getElementById("name").value;
if(!(/^[\u4e00-\u9fa5a-z]+$/gi.test(idName))){
$("#whole").show();
$("#content").hide();
$("#confirm").show();
$("#allright").text("姓名");//这个是公共弹出框的文字
document.getElementById("name").value='';
return false;
}
}
//姓名禁止输入特殊字符结束
HTML代码:
<input class="form-control" id="name" placeholder="姓名" type="text" style="width:198px;float:left;" onblur="checkName()">
<input class="form-control" placeholder="手机号" type="text" style="width:198px;float:left;" onblur="checkPhone()" id="tel">
<input class="form-control" id="idCard" placeholder="身份证" type="text" style="width:198px;float:left;" onblur="checkCard()" />
阅读全文
0 0
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- 匹配正则
- 正则匹配
- 正则匹配
- 正则匹配
- 正则匹配
- BZOJ3195: [Jxoi2012]奇怪的道路(状压DP)
- Java使用FilenameFilter过滤文件
- 几款用jQuery写的h5小游戏
- nsi学习之 软件重复安装不可以改路径
- javac编译提示编码GBK的不可映射字符
- 正则匹配
- otsu
- 安卓头像设置
- Principles of training multi-layer neural network using backpropagation
- git忽略跟踪文件修改
- 一列数的规则如下:1、1、2、3、5、8、13、21、34…… 求第30位数是多少,用递归算法实现。
- Android Studio 下的Kotlin HelloWorld
- 关于ajax跨域访问,Access-Control-Allow-Origin 404的简单解决办法
- TextView跑马灯效果