<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkIP (InField, I_chaMsg) {
var chaIPPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
var arrIP = InField.value.match(chaIPPattern);
if (InField.value.length == 0) {
return true;
}
if (InField.value == "0.0.0.0") {
alert("請注意,IP 位址不能為 0.0.0.0 !");
InField.focus();
InField.select();
return false;
} else if (InField.value == "255.255.255.255") {
alert("請注意,IP 位址不能為 255.255.255.255 !");
InField.focus();
InField.select();
return false;
}
if (arrIP == null) {
alert("請注意,IP 位址格式錯誤 !");
InField.focus();
InField.select();
return false;
} else {
for (indI = 0; indI < 4; indI++) {
intSegment = arrIP[indI + 1];
if (intSegment > 255) {
alert("請注意,IP 位址格式錯誤 !");
InField.focus();
InField.select();
return false;
}
if (indI == 3) {
if ( (intSegment == 0) || (intSegment == 255) ) {
alert("請注意,IP 位址格式錯誤 !");
InField.focus();
InField.select();
return false;
}
}
}
}
alert('正確的 IP 位址 !');
return true;
}
//-->
</Script>
</HEAD>
<BODY>
<form>
IP Address:
<input size=15 name="IPvalue">
<input type="button" value=" 檢 查 " onClick="checkIP(document.forms[0].IPvalue)";>
</form>
<p><center>
</center><p>