📢 Moderators Needed 🚀

Moderators are needed with resources to post or have access to resources to post. Submit an application to be considered.
B

RSS Cancelling form submit by `e.preventDefault()` is not working

B

BredyAK

Guest
Guest or Bot
I'm trying to create a plugin. I want to use js to cancel a form submit by following code:
JavaScript:

Code:
XF.on(form, 'ajax-submit:before', XF.proxy(this, 'beforeSubmit'));
// ...
function beforeSubmit(e) {
    console.log('beforeSubmit:', this.submitting);
    e.preventDefault();
    this.submitting = true;
}

Expected: When I click the submit button, it won't submit and console logs beforeSubmit: false.

Actually: Console shows beforeSubmit: false, but then it was submitted.

XenForo...

Read more

Continue reading...
 
Similar content Most view View more
Back
Top