欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS驗(yàn)證IP,子網(wǎng)掩碼,網(wǎng)關(guān)和MAC的方法

 更新時(shí)間:2015年07月02日 10:36:36   作者:tianmo2010  
這篇文章主要介紹了JS驗(yàn)證IP,子網(wǎng)掩碼,網(wǎng)關(guān)和MAC的方法,涉及javascript正則表達(dá)式的相關(guān)使用技巧,需要的朋友可以參考下

本文實(shí)例講述了JS驗(yàn)證IP,子網(wǎng)掩碼,網(wǎng)關(guān)和MAC的方法。分享給大家供大家參考。具體如下:

<!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>測(cè)試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;
  }
   //驗(yàn)證ip合法性
   if(myform.ip.value.match(reg)) 
   {  
   // return true;
   }
   else 
   {
   alert ("IP不合法");
   myform.focus();
   return false;
   }
  if(myform.zwym.value == "")
  {
   alert ("子網(wǎng)掩碼不能為空");
   myform.focus();
   return false;
  }
  //驗(yàn)證子網(wǎng)掩碼合法性
   if(myform.zwym.value.match(reg)) 
   {  
   // return true;
   }
   else 
   {
   alert ("子網(wǎng)掩碼不合法");
   myform.focus();
   return false;
   }
   //
  if(myform.gateway.value == "")
  {
   alert ("網(wǎng)關(guān)不能為空");
   myform.focus();
   return false;
  }
   //驗(yàn)證網(wǎng)關(guān)合法性
   if(myform.gateway.value.match(reg)) 
   {  
   // return true;
   }
   else 
   {
   alert ("網(wǎng)關(guān)不合法");
   myform.focus();
   return false;
   }
   //MAC
   if(myform.mac.value == "")
  {
   alert ("MAC不能為空");
   myform.focus();
   return false;
  }
   //驗(yàn)證mac合法性
   if(myform.mac.value.match(reg)) 
   {  
   // return true;
   }
   else 
   {
   alert ("MAC不合法");
   myform.focus();
   return false;
   }
 }   
//--> 
</script><body>
<form method="post" name="myform" onSubmit="return checkdata();">
    <table width="708" height="253" border="1" id="table1"  >
    <tr>
     <td width="186" height="53" ><div align="center">IP 地址:</div></td>
     <td width="506" height="53">&nbsp;&nbsp;
     <input type="text" name="ip" size="15" maxlength="15" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF0000">*</font>不能為空,必須填寫(xiě)</td>
    </tr>
    <tr>
     <td width="186" height="45" ><div align="center">子網(wǎng)掩碼:</div></td>
     <td width="506" height="45" >&nbsp;&nbsp;&nbsp;<input type="text" name="zwym" size="15" maxlength="15" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF0000">*</font>不能為空,必須填寫(xiě)</td>
    
    </tr>
    <tr>
     <td width="186" height="46" ><div align="center">網(wǎng) 關(guān):</div></td>
     <td width="506" height="46">&nbsp;&nbsp;
     <input type="text" name="gateway" size="15" maxlength="15" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF0000">*</font>不能為空,必須填寫(xiě)</td>
    </tr>
    <tr>
     <td width="186" height="48"><div align="center">MAC地址:</div></td>
     <td width="506" height="48" >&nbsp;&nbsp;
     <input type="text" name="mac" size="15" maxlength="15" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FF0000">*</font>不能為空,必須填寫(xiě)</td>
    </tr>
    <tr><!---changeinfo(ip.value,zwym.value,mac.value,reboot)-->
    <!-- onClick="changeinfo(ip.value,zwym.value,gateway.value,mac.value)"---->
     <td height="47" colspan="2" align="center"><input type="submit" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" />
     </td>
    </tr>
    </table>
   </form>
</body>
</html>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論