I have a form which is being submitted by ajax. Before submission, there’s a function which checks if a textarea in the form is empty before submitting. if it is empty, I need to stop the script and show a modal box AND prevent the submission of data to proceed.
How do I stop execution? Do I use
break;
?
Nope, you generally use
return;Of course the exact details will vary depending on your implementation. You may need to
return false;, for instance, and manually check the return value to see whether or not to keep executing script in the calling function.