<html>
<head>
<script language="javascript" type="text/javascript">
/*判断IP的函数*/
function checkip(form)
{
var pattern=/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
flag_ip=pattern.test(form.ipv.value);
if(!flag_ip)
{
alert("错误的ip!");
return false;
}
}
/*判断域名的函数*/
function checkdomain(form)
{
var doname = /^([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))$/;
var flag_domain = doname.test(form.domainv.value);
if(!flag_domain){
alert("不是正确的域名");
form.domainv.focus();
return false;
}
}
</script >
</head>
<body>
<form name="ip" method="get" onsubmit="return checkip(this)">
<input size="50" type="text" name="ipv" value="ip地址" style="color:#999999;padding-top: 2px;"/><input type="submit" value="查IP" name="ip_submit"/>
</form>
<form name="domain" method="get" onsubmit="return checkdomain(this)">
<input size="50" type="text" name="domainv" value="域名"style="color:#999999;padding-top: 2px;"/><input type="submit" value="域名" name="domain_submit"/>
</form>
</body>
</html>
}