JS对手机号码和验证码、QQ号码进行验证
程序员文章站
2022-04-04 12:54:02
...
//调用layer
var layerCommon = function(content) {
layer.open({
content: content,
skin: 'msg',
time: 1.5
});
}
//手机号码
var numberTel = function(num) {
if (num == "") {
layerCommon("请输入手机号");
return true;
} else if (!(/^1[3|4|5|7|8]\d{9}$/.test(num))) {
layerCommon('手机号不符合规范');
return true;
}
}
//数字验证码
var numberCode = function(num) {
if (num == "") {
layerCommon("请输入验证码");
return true;
} else if (!(/^\d{6}$/.test(num))) {
layerCommon('验证码不符合规范');
return true;
}
}
//qq
var qq_num = $('#xxx').val();
if (qq_num != '') {
if (!/^[1-9][0-9]{4,14}$/.test(qq_num)) {
layer.open({
content: '请输入正确的QQ号码',
skin: 'msg',
time: 1
});
}