I have a form which I want to submit only if a condition is true. But there is also a case in which I want to programmatically.
Following works when manually submitting the form:
<input type="submit" value="submit" onclick="return checkForTheCondition();"/> Following works for the submitting the form programmatically but it doesn't check for the condition for submitting the form.
$('form').submit(); So I tried to do the following for programmatically checking the condition before submitting the form but when I use the following code it doesn't even submit the form which was being done by $('form').submit();:
$('form').submit(function() { return checkForTheCondition(); }); checkForTheCondition() returns either true or false.
Is it possible to programmatically submit the form just like it works for manual form submission where it checks for a condition before submitting the form?