0

I am validating data at client side in asp.net validator by using following code snipet.

function ValidateData(){
if (!Page_ClientValidate("Validator1") || !Page_ClientValidate("Validator2")) {
     return false;
}
else{
     return true;
}

I called it on submit of button. But it showing validation messages of Validator1 group. Its not showing me validation messages of Validator2 group.

1 Answers1

0

Just gone through : see this link question , here its told - || operator short-circuits if the left condition is true.

Does a javascript if statement with multiple conditions test all of them?

If you want both , then cant you try like this :

function ValidateData(){

if (!Page_ClientValidate("Validator1")) 
{

    if (!Page_ClientValidate("Validator2")) 
    {
         return false;
    }
    else
    {
         return false;
    }


     return false;
}
else
{
     return true;
}

}

Just a random try , this code :)

Rigin

Community
  • 1
  • 1
Rigin
  • 177
  • 2
  • 17
  • Hi Rigin, Thanks for your answer. I tried it here but still it didnt solve my problem. similarly I tried function ValidateData(){ var res = true; if (!Page_ClientValidate("validator1")) { res = false; } if (!Page_ClientValidate("validator2")) { res = false; } return res; } – User Two CNPL Jun 30 '14 at 09:14
  • See this : http://stackoverflow.com/questions/1560812/page-clientvalidate-with-multiple-validationgroups-how-to-show-multiple-summ Below one answer is marked also . Can you try this : function fnJSOnFormSubmit() { var isGrpOneValid = Page_ClientValidate("valGrpOne"); var isGrpTwoValid = Page_ClientValidate("valGrpTwo"); var i; for (i = 0; i < Page_Validators.length; i++) { .... – Rigin Jun 30 '14 at 09:33
  • Thanks Rigin.. This above second solution solved by problem.. Thank you very much.. – User Two CNPL Jun 30 '14 at 11:33