0
我需要在發送表單數據之前使用jquery validator插件和自定義驗證方法來驗證表單數據。我需要說明jQuery Form Plugin是否具有beforeSend回調函數如果有的話,使用beforeSend回調函數有什麼基本要求?jQuery表單插件是否具有回調函數beforeSend:function()
$(function(){
\t var obtainFormMeta=function(formId){
\t \t return $(formId).data();
\t };
$('#form-asset-create').ajaxForm({
beforeSend:function(){
alert('before send');
$('#form-asset-create').validate();
},
success:function(){
var options=obtainFormMeta('#form-asset-create');
//alert('Aww snap! '+JSON.stringify(options));
alert("when success");
window.location=options.redirectUrl;
},
error:function(){
alert('Unable to add the asset');
}
});
});
我認爲存在爲每克 - http://malsup.com/jquery/form/#api –
我想你應該在'beforesend'返回'true'或'false'來繼續或取消請求 –
即使我的alert中沒有命中..並且我有我自定義的驗證方法來查詢字段是否有效 –