如何使用javascript从表单提交中获取返回值 [英] How to Get the return value from form submit using javascript
问题描述
亲爱的专家,
我被困在我的Asp.net项目中,
我是在我的项目中使用JQuery验证..我在我的Index.aspx页面中包含了一些Javascript文件和一小段javascript代码..这是下面的代码....
Dear Experts,
I am Stuck in my Asp.net project,
I am Using JQuery Validation in my project.. And i have Include some Javascript files and also a small piece of javascript code in my Index.aspx page.. Here is the below Code....
$('form').validationEngine();
当我点击提交按钮时,它会验证字段。
其中一个Javascript文件包含要验证的功能。它返回一个布尔值,如果表单获取错误则返回False,否则为True .....
我只是在该函数中发出警报并且我成功获得了返回布尔值。
这是以下代码..(此代码位于jquery.validationEngine.js文件中)
And When i click the submit button it validates the fields.
One of the Javascript file contains a function to validate. And it returns a boolean, if the form get error then it returns False else True.....
I just put an alert in that function and i successfully got the return boolean.
Here is the Below Code.. (This code is in "jquery.validationEngine.js" file)
_onSubmitEvent: function () {
var form = $(this);
var options = form.data('jqv');
options.eventTrigger = "submit";
// validate each field
// (- skip field ajax validation, not necessary IF we will perform an ajax form validation)
var r=methods._validateFields(form);
if (r && options.ajaxFormValidation) {
methods._validateFormWithAjax(form, options);
// cancel form auto-submission - process with async call onAjaxFormComplete
return false;
}
if(options.onValidationComplete) {
// !! ensures that an undefined return is interpreted as return false but allows a onValidationComplete() to possibly return true and have form continue processing
return !!options.onValidationComplete(form, r);
}
return r;
},
我需要得到这个返回布尔值Index.aspx页面.....
是否有任何Javascript代码可以获得返回值....
请帮帮我..
谢谢和问候,
Dileep .....
I need to get this return boolean in my Index.aspx page.....
Is there any Javascript code to get the return value....
Please help me..
Thanks and Regards,
Dileep.....
推荐答案
(' 形式'跨度>)validationEngine();
('form').validationEngine();
当我点击提交按钮时,它会验证字段。
其中一个Javascript文件包含要验证的功能。它返回一个布尔值,如果表单获取错误则返回False,否则为True .....
我只是在该函数中发出警报并且我成功获得了返回布尔值。
这是以下代码..(此代码位于jquery.validationEngine.js文件中)
And When i click the submit button it validates the fields.
One of the Javascript file contains a function to validate. And it returns a boolean, if the form get error then it returns False else True.....
I just put an alert in that function and i successfully got the return boolean.
Here is the Below Code.. (This code is in "jquery.validationEngine.js" file)
_onSubmitEvent: function () {
var form =
( this );
var options = form.data(' jqv'跨度>);
options.eventTrigger = submit;
// 验证每个字段
// ( - 跳过字段ajax验证,如果我们将执行ajax表单验证,则不需要)
var r = methods._validateFields(form);
if (r&& options.ajaxFormValidation){
methods._validateFormWithAjax(form,options);
// 取消表单自动提交 - 使用异步调用onAjaxFormComplete进行处理
< span class =code-keyword> return false ;
}
if (options.onValidationComplete){
// !!确保未定义的返回被解释为返回false但允许onValidationComplete()可能返回true并具有表单继续处理
return !! options.onValidationComplete(form,r);
}
return r;
},
(this); var options = form.data('jqv'); options.eventTrigger = "submit"; // validate each field // (- skip field ajax validation, not necessary IF we will perform an ajax form validation) var r=methods._validateFields(form); if (r && options.ajaxFormValidation) { methods._validateFormWithAjax(form, options); // cancel form auto-submission - process with async call onAjaxFormComplete return false; } if(options.onValidationComplete) { // !! ensures that an undefined return is interpreted as return false but allows a onValidationComplete() to possibly return true and have form continue processing return !!options.onValidationComplete(form, r); } return r; },
我需要得到这个返回布尔值Index.aspx页面.....
是否有任何Javascript代码可以获得返回值....
请帮帮我..
谢谢和问候,
Dileep .....
I need to get this return boolean in my Index.aspx page.....
Is there any Javascript code to get the return value....
Please help me..
Thanks and Regards,
Dileep.....
你好,
而不是将验证引擎附加到表格上你可以在您自己的提交处理程序中使用.validate方法。这样,您可以选择根据返回值采取适当的操作。请参阅此处的文档[ ^ ]
问候,
Hello,
Rather than attaching the validation engine to a form you can use .validate method in your own submit handler. That way you can chose to take an appropriate action based on the return value. See doc here[^]
Regards,
这篇关于如何使用javascript从表单提交中获取返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!