1

我正在尝试使用来自 ink.sapo.pt http://ink.sapo.pt/index.php/js/ui#formvalidator的表单验证器

我想拦截提交事件来编写我自己的代码,但总是调用以下事件:

$("#myform").submit(function() {
   alert('Handler for .submit() called.');
});

即使 onsubmit 属性为假。

基本上我希望ink.sapo.pt 验证我的表单,但我想在每次验证表单时使用我自己的代码。

4

2 回答 2

3

纯java脚本

<form id="myform" class="ink-form block" method="post" action="#" 
onsubmit="submitForm(this);">

function submitForm(formObj)
{
    if(SAPO.Ink.FormValidator.validate(formObj))
    {
          //Button Action
    }

}
于 2013-02-05T11:51:23.210 回答
1

尝试这个:

$("#myform").submit(function(ev) {
   ev.preventDefault();
   alert('Handler for .submit() called.');
});

基本上,您可以猜到,添加的行所做的是避免指定事件的默认行为。

于 2013-02-05T11:35:05.027 回答