jQuery: Button cause validation

前端 未结 3 1905
半阙折子戏
半阙折子戏 2021-01-25 17:15

In my form I have a normal submit button which validate my form with, for example, I have

$(\"#formTest\").submit(function (e) {
        alert(\'test\');
});

&l         


        
3条回答
  •  孤街浪徒
    2021-01-25 17:46

    you will want to make a handler for the button, and put a preventDefault() on it's event.

    $('button').click(function(e){
        e.preventDefault();
        alert('i clicked!');
    });
    

提交回复
热议问题