心灵科技(idcsea_com),海外专业IDC服务商!

查看完整版本: 校验IP地址是否合法,JavaScript

安祥的夜 2008-5-5 14:25

校验IP地址是否合法,JavaScript

[table=72%,#ffffff][tr][td][/td][td=1,1,97%][table][tr][td]校验IP地址是否合法,JavaScript
function chkIP(ipStr){
//参数格式校验 成功继续,失败返回-1
ipStr = ipStr.replace(/\s/g,"");
var reg = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
if(reg.test(ipStr) == false){
return -1;
}
//ip地址合法性校验 成功继续 ,失败返回-2
详情可点击:[url=http://www.oneedu.net/html/Learning/4747.html][color=#261cdc]http://www.oneedu.net/html/Learning/4747.html[/color][/url]
网站:[url=http://www.oneedu.net/][color=#261cdc]http://www.oneedu.net[/color][/url]
http:/[url=http://www.21wsh.com/][color=#261cdc]www.21wsh.com[/color][/url]
[/td][/tr][/table][/td][/tr][tr][td][/td][/tr][/table]

xlas 2008-5-5 17:36

楼上是否自己测试过?
感觉楼主在灌水?
1,是否测试过?
2,只转载那么一小段,是突出重点还是??
3,文中提及的函数[font=Times New Roman]chkIP怎么使用..[/font]
[font=Times New Roman]4.感觉他提供的函数过于复杂....[/font]
[font=Times New Roman][/font]
[font=Times New Roman]................[/font]

[[i] 本帖最后由 xlas 于 2008-5-5 17:42 编辑 [/i]]
页: [1]
查看完整版本: 校验IP地址是否合法,JavaScript