【问题标题】:HTML input 'required' is not working even in a form即使在表单中,HTML 输入“必需”也不起作用
【发布时间】:2018-10-29 10:57:57
【问题描述】:

我有一个文本框和一个带有“必需”属性的清单,当我按下按钮转到下一页而不填写两个输入时,它们不会验证它们是否已填写。

<form id="form" method="" action="">
   <input type="text" name="dressPrice" id="price" class="control" onkeypress="return numberFilter(event)" dir="rtl" onpaste="return false" required />
   <input type="checkbox" id="cbox1" required /><label class="tac-label"> I accept the <a href="terms-and-conditions.html" class="tac-link">terms and conditions.</a>

   <a href="buy-step-02.html" class="btn is-small" type="submit">Search</a>
</form>

最奇怪的部分是,我有另一个带有表单的 HTML 页面,并且那里输入的“必需”属性工作得很好。任何人都知道为什么会发生这种情况?

我认为这不是兼容性问题。

【问题讨论】:

标签: html forms


【解决方案1】:

使用 input insted 或 a 。 还有一个缺失的&lt;/label&gt;

<form id="form" method="" action="buy-step-02.html">
   <input type="text" name="dressPrice" id="price" class="control" onkeypress="return numberFilter(event)" dir="rtl" onpaste="return false" required />
   <input type="checkbox" id="cbox1" required /><label class="tac-label"> I accept the <a href="terms-and-conditions.html" class="tac-link">terms and conditions.</a>
</label>
   <input  class="btn is-small" type="submit" value="Submit"/>
</form>

【讨论】:

    猜你喜欢
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    • 2013-06-08
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    相关资源
    最近更新 更多