源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
楼主: ttx9n

[正则表达式] ip138中各种客户端验证js代码

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2009-12-9 02:58:01 | 显示全部楼层 |阅读模式
包括ip验证,身份证验证,手机号码验证,电话号码,邮政编码验证,域名验证等,其实好的代码,都在应用中,大家多去扒代码吧。

复制代码 代码如下:
function checkIP()
{
var ipArray,ip,j;
ip = document.ipform.ip.value;

if(/[A-Za-z_-]/.test(ip)){
if (ip.indexOf(" ")>=0){
ip = ip.replace(/ /g,"");
document.ipform.ip.value = ip;
}
if (ip.toLowerCase().indexOf("http://")==0){
ip = ip.slice(7);
document.ipform.ip.value = ip;
}
if(!/^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|(io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))$/.test(ip)){
alert("不是正确的域名");
document.ipform.ip.focus();
return false;
}
}
else{
ipArray = ip.split(".");
j = ipArray.length
if(j!=4)
{
alert("不是正确的IP");
document.ipform.ip.focus();
return false;
}

for(var i=0;i<4;i++)
{
if(ipArray[i].length==0 || ipArray[i]>255)
{
alert("不是正确的IP");
document.ipform.ip.focus();
return false;
}
}
}
}

function checkMobile(){
var sMobile = document.mobileform.mobile.value
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sMobile))){
alert("不是完整的11位手机号或者正确的手机号前七位");
document.mobileform.mobile.focus();
return false;
}
window.open('', 'mobilewindow', 'height=197,width=350,status=yes,toolbar=no,menubar=no,location=no')
}

function checkZip(){
var sZip = document.zipform.zip.value
if(!(/^\d{4,6}$/.test(sZip))){
alert("请输入邮政编码前4-6位");
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}

function checkZone(){
var sZone = document.zoneform.zone.value
if(!(/^0\d{2,6}$/.test(sZone))){
alert("请输入以“0”开头的3-7位区号");
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}

function checkArea2Zip(){
var sArea = document.area2zipForm.area.value
if(sArea==""){
alert("请输入地址");
document.area2zipForm.area.focus();
return false;
}
if(sArea.length<2){
alert("地址至少要有2个字");
document.area2zipForm.area.focus();
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}

function checkArea2Zone(){
var sArea = document.area2zoneForm.area.value
if(sArea==""){
alert("请输入地址");
document.area2zoneForm.area.focus();
return false;
}
if(sArea.length<2){
alert("地址至少要有2个字");
document.area2zoneForm.area.focus();
return false;
}
window.open('','searchwindow','height=197,width=400,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes')
}

function checkID(){
var sID = document.IDform.userid.value
if(!(/^\d{15}$|^\d{18}$|^\d{17}[xX]$/.test(sID))){
alert("请输入15位或18位身份证号");
document.IDform.userid.focus();
return false;
}
}
//-->
</script>

回复

使用道具 举报

0

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
25089
发表于 2022-10-3 01:03:10 | 显示全部楼层
很不错的样子
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
23997
发表于 2022-12-9 04:23:49 | 显示全部楼层
下载来瞧瞧
回复 支持 反对

使用道具 举报

15

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
25472
发表于 2023-1-9 20:49:27 | 显示全部楼层
而快乐你们快乐马年快乐
回复 支持 反对

使用道具 举报

4

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
25270
发表于 2023-1-20 01:40:34 | 显示全部楼层
借款金额看了就立刻
回复 支持 反对

使用道具 举报

2

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
25227
发表于 2024-4-26 22:20:23 | 显示全部楼层
论坛有你更精彩!
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
23997
发表于 2024-5-10 23:58:59 | 显示全部楼层
天天源码社区。。。。
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
20152
发表于 2024-5-11 09:29:03 | 显示全部楼层
收下来看看怎么样
回复 支持 反对

使用道具 举报

0

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
23931
发表于 2024-6-8 20:04:59 | 显示全部楼层
很不错的玩意
回复 支持 反对

使用道具 举报

2

主题

2万

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
24607
发表于 2024-10-5 09:13:01 | 显示全部楼层
终于找到了,我擦
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2025-2-11 16:13 , Processed in 0.198258 second(s), 41 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表