手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >JS验证IP,子网掩码,网关和MAC的方法
JS验证IP,子网掩码,网关和MAC的方法
摘要:本文实例讲述了JS验证IP,子网掩码,网关和MAC的方法。分享给大家供大家参考。具体如下:?123456789101112131415161...

本文实例讲述了JS验证IP,子网掩码,网关和MAC的方法。分享给大家供大家参考。具体如下:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN /TR/xhtml1/DTD/xhtml1-transitional.dtd html xmlns=/1999/xhtml meta http-equiv=Content-Type content=text/html; charset=gb2312 title测试IP/title /headscript 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; } } //-- /scriptbody form method=post name=myform onSubmit=return checkdata(); table width=708 height=253 border=1 id=table1 td width=186 height=53div align=centerIP 地址: td width=506 height=53 input type=text name=ip size=15 maxlength=15 /font color=#FF0000*/font不能为空,必须填写 td width=186 height=45div align=center子网掩码: td width=506 height=45 input type=text name=zwym size=15 maxlength=15 /font color=#FF0000*/font不能为空,必须填写 td width=186 height=46div align=center网 关: td width=506 height=46 input type=text name=gateway size=15 maxlength=15 /font color=#FF0000*/font不能为空,必须填写 td width=186 height=48div align=centerMAC地址: td width=506 height=48 input type=text name=mac size=15 maxlength=15 /font color=#FF0000*/font不能为空,必须填写 !---changeinfo(ip.value,zwym.value,mac.value,reboot)-- !-- onClick=changeinfo(ip.value,zwym.value,gateway.value,mac.value)---- td height=47 colspan=2 align=centerinput type=submit value=提交 input type=reset value=重置 /table /form /body /html

希望本文所述对大家的javascript程序设计有所帮助。

【JS验证IP,子网掩码,网关和MAC的方法】相关文章:

JavaScript判断数组是否包含指定元素的方法

JS验证IP,子网掩码,网关和MAC的方法

jquery预加载图片的方法

js控制网页前进和后退的方法

jQuery实现dialog设置focus焦点的方法

JS动画效果打开、关闭层的实现方法

删除javascript所创建子节点的方法

jQuery取消ajax请求的方法

js兼容火狐获取图片宽和高的方法

JS实现简单路由器功能的方法

精品推荐
分类导航