锋芒神话霜 2019-05-11 11:13 采纳率: 50%
浏览 2073
已结题

求解关于html input标签中利用pattern属性和正则表达式没用的问题

<html>
  <head>
    <title>查看/修改</title>
     <script language="JavaScript" src="script/trim.js"></script>
     <script language="JavaScript">
       function check(){

         document.all.mf.submit();
       }
     </script>
  </head>
  <body bgcolor="#EBF5FD">
    <jsp:useBean id="userBean" class="wyf.zrk.UserBean" scope="session"/>
    <table width="100%" height="44" bgcolor="#206AB3">
      <tr align="center"><td>
        <font color="#FFFFFF" size="5">电表信息管理</font>
        <font color="#FFFFFF" size="2">--电表信息添加</font>
      </td></tr>
    </table>
    <table>
      <tr><td><a href="javascript:history.back()">
        <img border="0" src="img/back.jpg"/></a>
      </td></tr>
    </table>
    <hr color="black" size="1"/>    
    <form action="ManageServlet" method="post" id="mf">
    <table width="80%" border="0" cellspacing="1" bgcolor="black" align="center">   
      <tr bgcolor="white">
        <td align="center">管理员姓名:</td>
        <td><input name="name" id="name" /></td>
      </tr>
      <tr bgcolor="white">
        <td align="center">居住地址:</td>
        <td>
          <select name="address">
          <% 
            //获取WebApplicationContext
            WebApplicationContext wac=
               WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
            DButil db = (DButil)wac.getBean("DButil");
            List<String> address = db.getHouseAddress();

            for(String name:address){

            %>
                <option value="<%= name %>" ><%= name %></option>
            <% 
                }
             %>
          </select>
        </td>
      </tr>
      <tr bgcolor="white">
        <td align="center">电表类型:</td>
        <td><input name="mtype" id="mtype" /></td>
      </tr>
      <tr bgcolor="white">
        <td align="center"> 电表型号:</td>
        <td><input name="machine" id="machine" /></td>
      </tr>
      <tr bgcolor="white">
        <td align="center">运营商:</td>
        <td><input name="company" id="company" /></td>
      </tr>
      <tr bgcolor="white">
        <td align="center">安装时间:</td>
        <td><input name="cometime" id="cometime" /></td>
      </tr> 
      <tr bgcolor="white">
        <td align="center">所在区域:</td>
        <td><input name="region" id="region" /></td>
      </tr>
    </table>
    <table align="center">
      <tr>
        <td><img border="0" src="img/xg.gif" id="xg" onclick="JavaScript:check()"
              style="cursor:hand"
              onmouseover="document.all.xg.src='img/xga.gif'"
              onmouseout="document.all.xg.src='img/xg.gif'"
              onmouseup="document.all.xg.src='img/xga.gif'"         
              onmousedown="document.all.xg.src='img/xgb.gif'"/></td>
        <td><img border="0" src="img/cze.gif" id="cz" onclick="JavaScript:document.all.mf.reset()"
              style="cursor:hand"
              onmouseover="document.all.cz.src='img/czd.gif'"
              onmouseout="document.all.cz.src='img/cze.gif'"
              onmouseup="document.all.cz.src='img/czd.gif'"         
              onmousedown="document.all.cz.src='img/czc.gif'"/></td>
      </tr>
    </table>
    <input type="hidden" name="action" value="adduser"/>


    </form>
  </body>
</html>

我想在 安装时间 那里的input后面添加确认格式为yyyy-mm-dd的正则表达式,上但加上去后却会直接跳过,求大神帮忙,顺便再求大神解惑一下javascript的check()方法和input的submit属性的区别,我这个例子可以改成用submit的方法吗,我现在无论怎么加正则表达式,我下面点击下面的图片都会运行check方法直接跳转,我该怎么处理才好?

  • 写回答

3条回答 默认 最新

  • lllomh 2019-05-11 14:17
    关注

    提交的时候 必须要在form 里面 用 或者 标签提交才能生效的,点击按钮后才生效。希望采纳

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?