为什么 Parsley 验证字段显示:none?
Why is Parsley validating fields with display: none?
我正在使用欧芹来验证表单,我正在尝试对其进行设置,以便在您单击下一步按钮时无法更改页面,除非正确填写当前页面。但是它正在验证 div 中包含的字段 style="display: none;"
这是一个字段的例子
<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>
有没有办法让欧芹忽略 div 具有 style="display:none;" 的所有元素?
您只需在 input
上添加 data-parsley-excluded="true"
。
data-parsley-excluded #2.1 | If set to true
, Parsley will ignore this field when binding a form.
我正在使用欧芹来验证表单,我正在尝试对其进行设置,以便在您单击下一步按钮时无法更改页面,除非正确填写当前页面。但是它正在验证 div 中包含的字段 style="display: none;"
这是一个字段的例子
<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>
有没有办法让欧芹忽略 div 具有 style="display:none;" 的所有元素?
您只需在 input
上添加 data-parsley-excluded="true"
。
data-parsley-excluded #2.1 | If set to
true
, Parsley will ignore this field when binding a form.