jQuery表单提交参数检查

我可以在$('#formid').submit(function() { });使用jQuery拦截/查询表单提交值$('#formid').submit(function() { }); 呼叫? 我无法检查页面中的值,因为它是我需要检查的特定提交按钮。 我发现这个http://geekswithblogs.net/renso/archive/2009/09/09/intercept-a-form-submit-with-jquery-and-prevent-or-allow.aspx并且它在FF中工作,但不是在IE8中,不幸的是,这没有帮助。 我也不想将提交代码附加到按钮,因为我希望制作一些通用的代码,我可以插入一整套表单。

干杯

MH

最新的jQuery 1.4现在支持提交事件的“实时” – 这意味着您不必将所有表单附加到单个处理程序。 Paul Irish在这里提供了一个很好的例子,涵盖了你所问的内容:

http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish

这是我自己的看法:

 jQuery(document).ready(function() { var pageForms = jQuery('form'); pageForms.find('input[type="submit"]').live('click', function(event) { var submitButton = this; var parentForm = jQuery(jQuery(this).parents('form')[0]); parentForm.data('submit-button',submitButton); }); pageForms.live('submit', function(event) { // Prevent form-submission. You can do this conditionally later, of course event.preventDefault(); // The form that was submitted var theForm = jQuery(this); // Detect which submit button was pushed var submitButton = theForm.data('submit-button'); console.log('submitButton = ',submitButton.value); }); }); 

HTML:

 

http://jsbin.com/equho3/6/edit

编辑 – 对不起,我在这里发布了一个与你的链接相匹配的例子! 我现在提供了一个跨浏览器的解决方案。