Prevent submit button with onclick event from submitting

后端 未结 5 1667
一向
一向 2020-12-17 10:21

I want to prevent a submit button with onclick event from submitting:

$j(\'form#userForm .button\').click(function(e) {
    if ($j(\"#zip_field\").val() >         


        
5条回答
  •  别那么骄傲
    2020-12-17 10:44

    Best way is to do everything inside your submit event handler of the form. Remove the inline onclick and run it inside the submit function

    $j('#userForm').submit(function(e) {
        if (+$j("#zip_field").val() > 1000){
            alert('Sorry we leveren alleen inomstreken hijen!');
            return false;
        }
        return myValidator(userForm, 'savecartuser');
    });
    

提交回复
热议问题