JS驗(yàn)證IP,子網(wǎng)掩碼,網(wǎng)關(guān)和MAC的方法
本文實(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"> <input type="text" name="ip" size="15" maxlength="15" /> <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" > <input type="text" name="zwym" size="15" maxlength="15" /> <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"> <input type="text" name="gateway" size="15" maxlength="15" /> <font color="#FF0000">*</font>不能為空,必須填寫(xiě)</td> </tr> <tr> <td width="186" height="48"><div align="center">MAC地址:</div></td> <td width="506" height="48" > <input type="text" name="mac" size="15" maxlength="15" /> <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="提交" /> <input type="reset" value="重置" /> </td> </tr> </table> </form> </body> </html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
- 深入了解JavaScript中的二進(jìn)制操作及位掩碼應(yīng)用
- php和js實(shí)現(xiàn)根據(jù)子網(wǎng)掩碼和ip計(jì)算子網(wǎng)功能示例
- JS 根據(jù)子網(wǎng)掩碼,網(wǎng)關(guān)計(jì)算出所有IP地址范圍示例
- js針對(duì)ip地址、子網(wǎng)掩碼、網(wǎng)關(guān)的邏輯性判斷
- js驗(yàn)證IP及子網(wǎng)掩碼的合法性有效性示例
- JavaScript在ASP頁(yè)面中實(shí)現(xiàn)掩碼文本框效果代碼
- 使用 JavaScript 在沒(méi)有插件的情況下輸入文本掩碼的示例詳解
相關(guān)文章
淺析JS中對(duì)函數(shù)function的理解(基礎(chǔ)篇)
我們知道,在js中,函數(shù)實(shí)際上是一個(gè)對(duì)象,每個(gè)函數(shù)都是Function類(lèi)型的實(shí)例,并且都與其他引用類(lèi)型一樣具有屬性和方法。下面給大家談下對(duì)JS中函數(shù)function的理解,一起看看吧2016-10-10BootStrap Datepicker 插件修改為默認(rèn)中文的實(shí)現(xiàn)方法
bootstrap-datepicker 是一個(gè)非常優(yōu)秀的時(shí)間選擇插件,默認(rèn)是英文顯示日期的,通過(guò)下面幾個(gè)小修改讓其支持默認(rèn)中文。下面通過(guò)本文給大家介紹BootStrap Datepicker 插件修改為默認(rèn)中文的實(shí)現(xiàn)方法,一起看看吧2017-02-02JavaScript動(dòng)態(tài)加載樣式表的方法
這篇文章主要介紹了JavaScript動(dòng)態(tài)加載樣式表的方法,涉及javascript操作樣式表的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-03-03服務(wù)器端的JavaScript腳本 Node.js 使用入門(mén)
觸爪伸向傳說(shuō)中的Server-Side Javascrpt。后端JS最出名無(wú)疑是Ryan Dahl的node.js,另一個(gè)是aptana IDE提供商搞出的jaxer,這里討論node.js的使用2012-03-03vant uploader實(shí)現(xiàn)上傳圖片拖拽功能(設(shè)為封面)
這篇文章主要介紹了vant uploader實(shí)現(xiàn)上傳圖片拖拽功能(設(shè)為封面),這個(gè)功能在日常生活中經(jīng)常會(huì)用到,操作非常方便,今天通過(guò)實(shí)例代碼介紹實(shí)現(xiàn)過(guò)程,需要的朋友可以參考下2021-10-10