【问题标题】:Is there a way to make sure at least ONE of a group of fields is filled, BEFORE sumitting a html form? ("required" is used just to one <input> field)在汇总 html 表单之前,有没有办法确保至少填写一组字段中的一个? (“必填”仅用于一个 <input> 字段)
【发布时间】:2020-10-23 20:29:10
【问题描述】:

如果我希望在提交表单之前填写此字段(价格),我会使用“必填”:

<input required="" type="number" name="price" />

如何确保在提交表单之前至少填写了某一组字段中的一个或多个字段?填一栏就够了。

【问题讨论】:

    标签: html required


    【解决方案1】:

    尝试在最后使用require,我相信它会使整个表单成为必需的。

    <input type="number" name="price" required/>
    

    【讨论】:

    • 谢谢,但也许我没有说清楚:如果至少填写表格的一个字段,这对我很有用。需要填写所有字段。
    猜你喜欢
    • 2014-10-16
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    • 2010-11-21
    • 1970-01-01
    • 2013-01-05
    • 2017-03-12
    相关资源
    最近更新 更多