繁体   English   中英

为什么Parsley用display:none验证字段?

[英]Why is Parsley validating fields with display: none?

我正在使用欧芹来验证表单,因此我尝试进行设置,因此当您单击下一个按钮时,除非正确填写了当前页面,否则无法更改页面。 但是,它使用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。 全部一起?

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

data-parsley排除的#2.1 | 如果设置为true ,则在绑定表单时,Parsley将忽略此字段。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM