简体   繁体   English

如何使用Parsley Js逐一验证表单字段

[英]How to Validate Form fields one by one with Parsley Js

I am trying to Validate a Form with Parsley JS But when I hit submit it's adding error class in all fields but I want that it should validate fields one by one. 我正在尝试使用Parsley JS验证表单,但是当我点击Submit时,它在所有字段中都添加了错误类,但我希望它应该逐个验证字段。

So if the 5 inputs are required and I it submits without filling any of them so want to show error in the 1st input only. 因此,如果需要5个输入,而我没有填写任何输入就提交,因此只想在第1个输入中显示错误。 after that if i fill 1st input and left the other 4 then it should show error in the second input only. 在那之后,如果我填写第一个输入,而离开其他四个,那么它应该仅在第二个输入中显示错误。 I am just using this code for my form now. 我现在只是在表单中使用此代码。

$('#formid').parsley( //nothing here for now );

Set a specific priority to each input in the order you want them validated. 按照要验证它们的顺序,为每个输入设置特定的优先级。 Parsley will stop validation as soon as an error is detected at a given priority level. 一旦在给定的优先级上检测到错误,欧芹将立即停止验证。

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

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