Manually triggered Abide validation in Zurb Foundation

痴心易碎 提交于 2019-12-11 11:49:40

问题


I'm trying to make myself a form, but I need to prevent some UX stuff depending on if a form was entered correctly. Is there an api for manually issuing the validation routine to a form's field? I know that I could listen to the post-validation events, but I actually need to start the validation from an external source.

Is this possible?


回答1:


You can dispatch a change event to the form with jQuery: $("#myForm").trigger("change");
It will trigger validation.




回答2:


The accepted trigger on the form did not work for me. Instead using $('#myForm').submit() successfully triggers the checks manually. If you're using an asynchronous form you would just need to do the right preventDefault and return false on the form so that it does not submit like a normal form. I solved this by adding a universal class / data-attribute called data-ajax-submit or ajax-submit for my forms.




回答3:


Based on the code from Foundation 5.5.3 you can try this one:

$('#my_form').trigger('validate.fndtn.abide');


来源:https://stackoverflow.com/questions/27487823/manually-triggered-abide-validation-in-zurb-foundation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!