jQuery表单插件和jQuery验证

时间:2012-04-23 15:41:46

标签: jquery ajax validation

尝试同时使用jQuery Form PluginjQuery Validate plugin,但即使必填字段为空,表单也会使用AJAX提交。这是我的代码:

// prepare the form when the DOM is ready 
$(document).ready(function() { 

     // bind form using ajaxForm 
     $('#contact-form').ajaxForm({ 
    // target identifies the element(s) to update with the server response 
    target: '#ajax-success', 

    // success identifies the function to invoke when the server response 
    // has been received; here we apply a fade-in effect to the new content 
    success: function() { 
        $('#contact-form-wrapper').hide();
        $('#ajax-success').fadeIn('slow'); 
    } 
    }); 
});

1 个答案:

答案 0 :(得分:0)

documentation for the validate plugin显示了如何执行此操作。

查看submitHandler函数。