proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« 批量设置 IP 的 shell 代码 | Main | 解压 .tar .tar.gz 文件中的个别文件的方法 »

October 13, 2006

判断 IP 的 javascript 代码

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2006/10/13/001111.html
http://windtear.net/archives/2006/10/13/001111.html

判断 IP 的 javascript 代码

function n(x) {
	return ( (!isNaN(x)) && x<=255 && x>=0);
}
function checkip(myform) {
	var ip=myform.q.value.split(".");
	if(ip[3]=="*" || ip[3]=="?") {
		ip[3]=1;
		myform.q.value=ip[0]+"."+ip[1]+"."+ip[2]+"."+ip[3];
	}
	if( ! ((ip.length==4)?(n(ip[0])&&n(ip[1])&&n(ip[2])&&n(ip[3])):false) ) {
		alert("IP 地址有误\n请重新输入!\n\n正确的格式举例: \n    166.111.1.1");
		myform.q.select();
		myform.q.focus();
		return false;
	}
}


<form method="post" onSubmit="return checkip(this);">
onClick="JavaScript:this.select()"
本blog WWW

Posted by windtear at October 13, 2006 11:53 PM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.