【问题标题】:Why is Parsley validating fields with display: none?为什么 Parsley 使用 display: none 验证字段?
【发布时间】:2019-07-22 19:16:48
【问题描述】:

我正在使用欧芹来验证表单,并且我正在尝试对其进行设置,以便在单击下一步按钮时无法更改页面,除非当前页面填写正确。但是,它正在验证包含在 style="display: none;"

的 div 中的字段

这是一个字段的示例

<div class="hidden tab" id="notAlwaysManitoban">
  <div class="field">
    <label for="residencybeforecanada">Where was your residency before your arrival in Manitoba? </label>
    <input type="text" name="residencybeforecanada" id="residencybeforecanada" data-parsley-required="true" data-parsley-required-message="Please enter where you lived before arriving in Manitoba">
  </div>
  <div class="field">
    <label for="arrivalInManitobaDate">Date of arrival in Manitoba (MM-YYYY)</label>
    <input type="text" name="arrivalInManitobaDate" id="arrivalInManitobaDate" class="dateChooserMY" placeholder="MM-YYYY" maxlength="7" data-parsley-required="true" data-parsley-validyear data-parsley-required-message="Enter date with the format MM-YYYY.">
  </div>

无论如何让欧芹忽略具有 style="display:none;" 的 div一起来?

【问题讨论】:

    标签: javascript jquery html validation parsley


    【解决方案1】:

    您只需在input 上添加data-parsley-excluded="true"

    数据-欧芹-排除 #2.1 |如果设置为true,Parsley 在绑定表单时会忽略该字段。

    https://parsleyjs.org/doc/index.html#usage-field

    【讨论】:

      猜你喜欢
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多