<code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>
测试IP
</title>
</head>
<script language="javascript">
< !---
function checkdata() {
var reg = /^(/d {
1,
2
} | 1 / d / d | 2[0 - 4] / d | 25[0 - 5])(/.(/d {
1,
2
} | 1 / d / d | 2[0 - 4] / d | 25[0 - 5])) {
3
}
$ / ;
if (myform.ip.value == "") {
alert("IP不能为空");
myform.focus();
return false;
}
//验证ip合法性
if (myform.ip.value.match(reg)) {
// return true;
} else {
alert("IP不合法");
myform.focus();
return false;
}
if (myform.zwym.value == "") {
alert("子网掩码不能为空");
myform.focus();
return false;
}
//验证子网掩码合法性
if (myform.zwym.value.match(reg)) {
// return true;
} else {
alert("子网掩码不合法");
myform.focus();
return false;
}
//
if (myform.gateway.value == "") {
alert("网关不能为空");
myform.focus();
return false;
}
//验证网关合法性
if (myform.gateway.value.match(reg)) {
// return true;
} else {
alert("网关不合法");
myform.focus();
return false;
}
//MAC
if (myform.mac.value == "") {
alert("MAC不能为空");
myform.focus();
return false;
}
//验证mac合法性
if (myform.mac.value.match(reg)) {
// return true;
} else {
alert("MAC不合法");
myform.focus();
return false;
}
}
//-->
</ script>
<body>
</body>
</html></code>
希望本文所述对大家的javascript程序设计有所帮助。
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!