Do not try to configure and cancel the send handler from your check function, do it the other way around: call the check from one send handler and only call .preventDefault()
if the check fails:
$(document).ready(function() { $('#ShoutTweet').submit(function(e) { if () { e.preventDefault(); } }); });
If all your checks pass, just do not call e.preventDefault()
and the send event will occur by default.
Alternatively, you can return false
from the submit handler to prevent the default:
$('#ShoutTweet').submit(function(e) { if (!someValidation()) return false; if (!secondValidation()) return false; if (someTestVariable != "somevalue") return false;
source share