Prevent submit button with onclick event from submitting
I want to prevent a submit button with onclick event from submitting: $j('form#userForm .button').click(function(e) { if ($j("#zip_field").val() > 1000){ $j('form#userForm .button').attr('onclick','').unbind('click'); alert('Sorry we leveren alleen inomstreken hijen!'); e.preventDefault(); return false; } }); This is the submit button: <button class="button vm-button-correct" type="submit" onclick="javascript:return myValidator(userForm, 'savecartuser');">Opslaan</button> It will show the "alert" function and also removes the onclick event, but the form is submitted anyway. Manually remove the