8 months ago

Jquery prevent default not working

Posted 8 months ago by pickab00

So I have a form submission which I am preventing the default. So the code looks something like this.


var allowSubmit = false;

if (!allowSubmit){

//run something here and say

var a = 1;

if (a != 1) {
    allowSubmit = false;
    allowSubmit = true;


I don't see the problem with this code. The e.preventDefault(); works just fine. But console logs 'works' and it is supposed to set the allowSubmit variable to true correct? Then why is my form not being submitted now that the allowSubmit is true and preventDefault is no longer true?

Please sign in or create an account to participate in this conversation.