【问题标题】:html5 form validation is not working when input type is submit is used当输入类型为提交时,html5 表单验证不起作用
【发布时间】:2014-02-19 08:19:06
【问题描述】:

您好,我想使用提交按钮验证输入类型 = 电子邮件字段。 我在页面中有两个表单元素。我正在打开一个 div(divForgotPassword) 作为模式。 但是 required 属性在 modal 内部不起作用。 下面是我的代码

<form id="form1" runat="server">

//一些元素

 <form id="form2" action="javascript:RetrievePassword();">
      <div id="divForgotPassword" style="display:none" title="Forgot password">

                  <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblForgotPassword" runat="server" Text="Email"></asp:Label>:
                        </td>
                        <td>
                            <input type="email" required="required" id="txtForgotEmail" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" style="background-image:url('Images/buttons/btn_send.png')" id="btnSend"  />
                        </td>
                    </tr>
                </table>


            </div>
</form>

【问题讨论】:

  • 您使用哪些浏览器进行测试?并非所有流行的浏览器都支持所有 HTML5 元素和属性:Browser Support for New HTML5 Input Attributes
  • Sandeep,您还没有在代码中为 input type = "email" 编写任何 html 标签。
  • 我用的是chrome浏览器,我想它支持html5..?

标签: html webforms


【解决方案1】:
<form id="form2" action="javascript:RetrievePassword();">
<div id="divForgotPassword"  title="Forgot password">
    <table>
        <tr>
            <td>
                <label for="txtForgotEmail">
                    EMAIL : </label>
            <td>

                <input type="email" required="required" id="txtForgotEmail" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" style="background-image:url('Images/buttons/btn_send.png')" id="btnSend" />
            </td>
        </tr>
    </table>
</div>

请找到这个演示DEMO

【讨论】:

    猜你喜欢
    • 2013-05-18
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    相关资源
    最近更新 更多