Is it possible to assign Multiple Validation Groups to a single Validation Control?

22,795

What about using two RequiredFieldValidator objects, one for Group1 and one for Group2?

Share:
22,795
Ananth
Author by

Ananth

a programmer by choice

Updated on July 09, 2022

Comments

  • Ananth
    Ananth almost 2 years

    I have a Form like this.

    UserID has to be validated when user clicks "Check Availability" and "Submit"enter image description here

    Hence "UserID" required field validator has to be assigned two grops.

    As if now it is assigned only Group1

     <asp:RequiredFieldValidator ID="UserIDRequiredFieldValidator" runat="server" ErrorMessage="Enter UserID"
                        ControlToValidate="txtUserID" ValidationGroup="Group1"></asp:RequiredFieldValidator>
    

    So is it possible to assign "Group1" and "Group2" to UserIDRequiredFieldValidator

    I have already gone through How to validate against Multiple validation groups? which talks about validating Group1 and Group2 when user clicks "Submit" which is a good alternate solution .

    Thanks in Advance

  • Ananth
    Ananth about 13 years
    Good Solution.. Definitely solves the issue..But is it not possible to assign multiple groups to a validation control ?
  • Ásgeir Gunnar Stefánsson
    Ásgeir Gunnar Stefánsson about 10 years
    No it is not possible but you can call Page.Validate("groupOne"); Page.Validate("groupTwo"); from code behind.
  • user1566694
    user1566694 almost 6 years
    I thought multiple validation groups was primarily to solve the problem of using multiple required field validators. They like to all fire (on blur) instead of accepting one false result is enough.