2
votes

I am working on an ASP .Net web application.
One of my ASPX page contains a custom TextBox control.

3 validation controls are applied to the TextBox :

  • 1 RequiredFieldValidator
    • ErrorMessage="*"
    • Display="Dynamic"
    • ValidationGroup="IdentityRequired"
  • 2 CompareValidator :
    • ErrorMessage="*"
    • ValidationGroup="Identity"

A custom JS function is executed when form is submitted.
The custom JS function contains the 2 following statements :

var b_RegExp = window.Page_ClientValidate('Identity');
var b_Required = window.Page_ClientValidate('IdentityRequired');

When b_Required is false then a star is displayed caused by the RequiredFieldValidator => OK !
When b_RegExp is false no star is displayed => KO !
Can anyone explain to me what is wrong please ?

1

1 Answers

1
votes

It seems that the last call to window.Page_ClientValidate determines the error messages to display.
No error messages (star) are displayed even if errors have been detected in the Identity group because the last call to window.Page_ClientValidate detects no error in the IdentityRequired group.

So I have changed my two JS statements as follows :

var b_Required = window.Page_ClientValidate('IdentityRequired');
var b_RegExp = false;
if (b_Required)
    b_RegExp = window.Page_ClientValidate('Identity');

And I have added Display="Dynamic" to the markup of my 2 CompareValidator controls.