Click here to Skip to main content
15,911,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

In the function which shows up the "Loading Icon", check if the page is valid:

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



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

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


Read more on Page_ClientValidate() here:
http://weblogs.asp.net/pirabdulwakeel/archive/2010/09/02/java-script-page-validation-page-clientvalidate.aspx[^]
 
Share this answer
 
v3
Comments
Jephunneh Malazarte 3-Feb-12 6:48am    
Hi Jyoth.

thank you for your suggestion. I am using that one now but i came accross something.
is it possible to turn-off the auto validation to my controls? instead i will do manual validation by executing Page_ClientValidate()? because what happen now is that the validation is being executed twice.
Jephunneh Malazarte 3-Feb-12 6:49am    
excellent link 5!
Jephunneh Malazarte 3-Feb-12 6:55am    
I have accepted the solution. I just disable the messagebox property of my summary validation to prevent displaying of error message twice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900