Prevent submit button with onclick event from submitting

后端 未结 5 1668
一向
一向 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:49

    I believe there is an easier way:

    $j('form#userForm .button').click(function(event) { // <- goes here !
        if ( parseInt($j("#zip_field").val(), 10) > 1000){
            event.stopPropagation();
        }   
    });
    

提交回复
热议问题