How to add additional settings on error in Contact form 7?

﹥>﹥吖頭↗ 提交于 2019-12-25 06:26:01

问题


I already know the function 'on_sent_ok' to add jQuery actions when the form is submitted with success. However I want to display a modal window alerting the user when there are submitting erros. There's some function like the one above, but to be called on errors?


回答1:


In version 3.3 new jQuery custom event triggers were introduced:

New: Introduce 5 new jQuery custom event triggers (invalid.wpcf7, spam.wpcf7, mailsent.wpcf7, mailfailed.wpcf7, submit.wpcf7).

See: http://contactform7.com/2012/09/24/contact-form-7-33/#more-2598

You can use invalid.wpcf7 like the example below:

$(".wpcf7").on('invalid.wpcf7',function(e){
  // Launch your modal window here
});



回答2:


Contact form 7 doesn't provide actions when submitted form contains errors. But Contact form 7 adds some specific classes on the HTML code. So with Jquery you can check if these classes exist or not and add some actions.



来源:https://stackoverflow.com/questions/30036688/how-to-add-additional-settings-on-error-in-contact-form-7

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