本文介绍了作法:验证过程中RequiredFieldValidator失败时调用javascript方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

是否可以使用RequiredFieldValidator在验证必填字段时出错时调用javascript函数?

我想调用javascript的原因是,如果发生必填字段验证错误,我将不希望隐藏加载图标.

Question

Is it possible to call javascript function on error in validation of the required field using RequiredFieldValidator?

The reason why i wanna call javascript is because i wan''t to hide loading icon if required field validation error occur.

推荐答案

function showLoadingIcon() {
if(Page_ClientValidate())
{
//show loading icon
}
else
{
//hide loading icon
}
}




PS:由于您只需要验证RequiredFieldValidators-对所有它们使用组名并按如下所示验证页面:




PS: Since you need to validate only the RequiredFieldValidators - use group name for all of them and validate the page as below:

if(Page_ClientValidate("GroupName")){
//Code Here
}



在此处阅读有关Page_ClientValidate()的更多信息:
http://weblogs.asp.net/pirabdulwakeel/archive/2010/09/02/java-script-page-validation-page-clientvalidate.aspx [ ^ ]



Read more on Page_ClientValidate() here:
http://weblogs.asp.net/pirabdulwakeel/archive/2010/09/02/java-script-page-validation-page-clientvalidate.aspx[^]


这篇关于作法:验证过程中RequiredFieldValidator失败时调用javascript方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 20:30