首页 技术 正文
技术 2022年11月15日
0 收藏 712 点赞 2,303 浏览 1344 个字

实现源码:

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />

<script type=”text/javascript” src=”http://www.daixiaorui.com/Public/js/jquery.min.js”></script>

<script type=”text/javascript”>

$(function(){

$(“#ck_mobile”).click(function(){

var mobile = $(“#mobile”).val();

if(!check_mobile(mobile)){

alert(“手机号码格式不正确”);

}else{

alert(“手机号码正确”);

}

});

$(“#ck_email”).click(function(){

var email = $(“#email”).val();

if(!check_email(email)){

alert(“email格式不正确”);

}else{

alert(“email正确”);

}

});

})

//检查手机号码

function check_mobile(mobile){

if(mobile.length != 11 || isNaN(mobile)){

return false;

}

mobile = mobile.substr(0,3);

//号段

var hd = new Array

('130','131','132','133','134','135','136','137','138','139','150','151','152','153','154','155','156','157','158','159','180','181','182','183','184','185','186','187','188','189'
,'141','142','143','144','145','146','147','148','149','171','172','173','174','175','176','177','178','179');

var i = hd.length;

while (i–) {

if (hd[i] == mobile) {

return true;

}

}

return false;

}

//验证邮箱是否正确

function check_email(email){

var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

if(!reg.test(email)){

return false;

}else{

return true;

}

}

</script>

<p>手机号:<input type=”text” id=”mobile”  /> <input type=”button” value=”验证手机号” id=”ck_mobile” /></p>

<p>Email:<input type=”text” id=”email”  /> <input type=”button” value=”验证邮箱格式” id=”ck_email” /></p>

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,997
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,356
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,139
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848