jQuery - Cancel form submit (using “return false”?)?

后端 未结 12 1673
盖世英雄少女心
盖世英雄少女心 2020-12-19 04:00

I\'m running into a bit of trouble while trying to cancel the submit of a form. I\'ve been following this tutorial (even though i\'m not making a login script), and it seems

12条回答
  •  渐次进展
    2020-12-19 04:24

    You have to do a sort of 'double return', or in other words, you have to return what is returned. So, you have your html:

    Than you just have a jquery function that is called onsubmit as you see above:

    function cancelSubmit() {
        return false; // return true if you want submission to carry through
    }
    

    You can put any sort of conditionals in the function above. It seems you simply want to cancel it though. Hope this helps for others that come across this answer.

提交回复
热议问题