I want to check if there's at least one checkbox that checked in a form after the submit button is clicked, if no, the the user should get message and the form SHOULDN'T be submit, so I wrote this code:
jQuery(document).ready(function ($) { $('#price_quote_create_invoice').click(function () { $('.price-quotes-table input[type="checkbox"]').each(function () { if ( $(this).is(':checked') ){ $('#post').submit(); return false; } else { alert("You didn't chose any checkbox!"); return false; } }) ; }); }); However, after I press ok on the alert box, the form does submit.
Any idea why this is happening?