Display loading gif after parsley.js validates form

点点圈 提交于 2019-12-12 04:40:02

问题


Have a an upload form with some required fields which uses parsley.js to validate. I want to display a loading gif after the form has been validated and the actual uploading starts.

I've tried using an onsubmit event to call a function which changes the visibility of the loading gif from hidden to visible. But the gif shows up when ever the upload button is clicked even if the form has not been validated.

Thanks in advance!


回答1:


You'll have to use Parsley events (http://parsleyjs.org/doc/index.html#psly-events-list) and do something like that:

$('#form').parsley().subscribe('parsley:form:validated', function (parsleyForm) {
  if (true === parsleyForm.validationResult )
     // display gif
  else
     // do something else, or nothing
});

Best



来源:https://stackoverflow.com/questions/23081887/display-loading-gif-after-parsley-js-validates-form

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