日期:2008-08-23  浏览次数:21049 次

<script language="javascript">
function checkIP(sIPAddress)
{


var sIPAddress=sIPAddress
var IPsplit;
var re=/^(\d{1,3}\.){3}\d{1,3}\/(\d{1,3}\.){3}\d{1,3}$/gi;
var chkflag=true;
var ErrMsg="你输入的是一个非法的IP地址段!\nIP段为::xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx(xxx为0-255)!"

if(sIPAddress.search(re)==-1){
chkflag=false;
}else{
IPsplit=sIPAddress.split("/");
IPsplit=IPsplit[0]+"."+IPsplit[1]
IPsplit=IPsplit.split(".");

for(i=0;i<8;i++){
if(IPsplit[i]>255){
chkflag=false;
break;
}
}
}
if(!chkflag)
alert(ErrMsg);
return chkflag
}
</script>
<input type="text" name="iptext" size=31>
<input type="button" value="Check" Onclick="checkIP(iptext.value);">