jquery validate conflict with script preventing double submission -


this question has answer here:

i'm using form generated toolset cred plugin has jquery.validate validation. i've got issues duplicated content generated when user clicks repeatedly submit button.

i've tried add code prevent multiple submissions

    $("form").submit(function() {         // submit more once return false         $(this).submit(function() {             return false;         });         // submit once return true         return true;     }); 

it works fine except fact if first time user submits form doesn't pass validation submit button doesn't work anymore.

could suggest tweak? carlo

you create global variable , check whether it's been changed. assuming it's regular form, page reload , send form again.

var hasbeensent = false;  $("form").on('submit',function(e){    if(hasbeensent != false){        e.preventdefault(); // should prevent sending form.    }else{        hasbeensent = true;    }    }) 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -