【问题标题】:Why the required attribute doesnt work inside the form为什么必需的属性在表单中不起作用
【发布时间】:2023-01-16 18:45:29
【问题描述】:

必需的属性在这种形式下不起作用。这怎么能解决?

 <form id="regform" action="PersonalDataAgreement.jsp" method="post" name="registration_form">
    <div class="register">
      <div class="input_field">
        <input type="text" placeholder="familyname" class="input" name="familyname" id="familyname" required>
      </div>
      <div class="input_field">
        <input type="text" placeholder="firstname" class="input" name="firstname"  id="firstname" required>
      </div>
      <div class="input_field">
        <input type="text" placeholder="secondname" class="input" name="secondname"  id="secondname" required>
      </div>
      <div class="btn"><a href="#" onclick="document.getElementById('regform').submit()">Register</a></div>
    </div>
    </form>

【问题讨论】:

标签: html forms jsp


【解决方案1】:

调用表单的submit() 方法绕过验证步骤。

请改用真正的提交按钮。应用 CSS 使其看起来像您想要的样子。

<button>Register</button>

【讨论】:

    【解决方案2】:
    Write this way
    required="required"
    

    【讨论】:

      【解决方案3】:

      将您的“注册”按钮更改为:

       <div class="btn"><button>Register</button></div>
      

      它工作正常。

      【讨论】:

        猜你喜欢
        • 2020-01-04
        • 1970-01-01
        • 2020-03-18
        • 2023-01-11
        • 2021-07-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-05
        相关资源
        最近更新 更多