JS动态增加文本框加IP地址判断

来源:互联网 发布:江恩轮中轮软件 编辑:程序博客网 时间:2024/05/01 17:56
<%@ page language="java" import="org.zhaohua.util.*,java.util.* , org.zhaohua.po.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>权限管理</title>    <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0">    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link href="<%=basePath %>css/ht_1.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="<%=basePath %>js/ip.js"></script><script type="text/javascript" src="<%=request.getContextPath()%>/js/fmSort.js"></script><script type="text/javascript"src="<%=request.getContextPath()%>/ajax/interface/FmSortManager.js"></script><script type='text/javascript'src='<%=request.getContextPath()%>/ajax/engine.js'></script><script type='text/javascript'src='<%=request.getContextPath()%>/ajax/util.js'></script><style>.a3{width:30;border:0;text-align:center}</style><script type="text/javascript">function check() {var ip1 = document.getElementsByName("ip1");var ip2 = document.getElementsByName("ip2");for(var i = 0 ; i < ip1.length ; i++) {if(ip1[i].value.match(/^/d{1,3}/./d{1,3}/./d{1,3}/./d{1,3}$/)){}else{alert("IP验证错误!");   return false;   }}for(var i = 0 ; i < ip2.length ; i++) {if(ip2[i].value.match(/^/d{1,3}/./d{1,3}/./d{1,3}/./d{1,3}$/)) { } else {alert("IP验证错误!");   return false;   }}}  function add(table1) {  var index = table1.rows.length;var nextRow = table1.insertRow(index);var arows = table1.rows;var acells = nextRow.cells;var isText = arows(nextRow.rowIndex).insertCell(acells.length);index++;index = index.toString();var str = 'IP段' + index + ':'isText.innerHTML = '<tr>'+   str +   ' ' +   '<td><input name=/"ip1/" type=/"text/"></td>' +   ' ' +   '--' +   ' ' +   '<td><input name=/"ip2/" type=/"text/"></td>' +   ' ' +   '<td><input type=/"button/" name=/"submit3/" class=/"an/" value=/"删除/" onclick=/"del(table1)/"></td>' +   '</tr>'      }  function del(table1) {  table1.deleteRow(1);  }</script>  </head><td><input type="button" name="Submit3" class="an" value="增加" onclick="add(table1)"></td>    <BODY>  <TABLE width="98%" border=0 align=center cellPadding=4 cellSpacing=1 borderColorLight=#cccccc borderColorDark=#ffffff>  <TBODY>  <TR align="center">    <TD width="100%" height=27 align=left class="header">     <table width="100%" border="0"cellspacing="0" cellpadding="0">        <tr>        <td width="86%" height=27 class="header" background="<%=basePath %>admin/Images/bg3.gif" >当前位置>>权限管理>>权限管理主页面</td>        </tr>      </table>      </TD>   </TR>   <TR align="center">      <TD height=27 align=left>      <form name="form1" method="post" action="<%=basePath %>bookSort.do?method=bookGL" onsubmit="return check();">        <TABLE class=tableborder cellSpacing=1 cellPadding=4 width="98%" align=center border=0>            <TR onMouseOver="this.style.backgroundColor='#F8F8F8';" onmouseout="this.style.backgroundColor='#FFFFFF';" bgColor=#ffffff>                <TD align=right height=25>分类名称</TD>              <TD width="83%" height=25>              <select name="bookSortSeq" class="an">            <%              List list = ServiceUtil.getBss().getBookSortResult();              for(int i = 0 ; i < list.size() ; i++) {              BookSort bs = (BookSort) list.get(i);            %>                <option value="<%=bs.getBookSortSeq() %>"><%=bs.getSortName() %></option>            <%} %>              </select>              </TD>            </TR>            <TR onMouseOver="this.style.backgroundColor='#F8F8F8';" onmouseout="this.style.backgroundColor='#FFFFFF';" bgColor=#ffffff>              <TD align=right height=25>登陆才能查看</TD>              <TD height=25>              <select name="flagLogin" class="an">                <option value="1">是</option>                <option value="0">否</option>              </select>                            </TD>            </TR>            <TR onMouseOver="this.style.backgroundColor='#F8F8F8';" onmouseout="this.style.backgroundColor='#FFFFFF';" bgColor=#ffffff>              <TD align=right width="17%" height=25>开放IP段</TD>              <TD height=25>              <table width="360" border="0" cellspacing="0" cellpadding="0" id="table1">                <tr>                  <td width="475">IP段1:                   <label>                  <input type="text" name="ip1">                  --                  </label>                    <label>                    <input type="text" name="ip2">                    </label>                 <input type="button" name="Submit32" class="an" value="增加" onClick="add(table1)"></td>                </tr>              </table>              </TD>            </TR>            <TR onMouseOver="this.style.backgroundColor='#F8F8F8';" onmouseout="this.style.backgroundColor='#FFFFFF';" bgColor=#ffffff>              <TD align=right height=25> </TD>              <TD height=25 align="center">              <table width="30%" border="0" cellspacing="0" cellpadding="0">                <tr>                  <td align="center"><input name="Submit2" type="submit" class="an" value="确定"></td>                  <td align="center"><input name="Submit2" type="reset" class="an" value="重置"></td>                  <td align="center"><input name="Submit2" type="button" class="an" value="调试" onClick="checkout(5)"></td>                </tr>              </table>              </TD>            </TR>            </table>            </form>           </TD>          </TR>          <TBODY id=mainBody>          </TBODY></TABLE></BODY></html>