20

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

Community
  • 1
  • 1
Ananth
  • 10,330
  • 24
  • 82
  • 109
  • 1
    Please check this an older but effective [post](http://stackoverflow.com/questions/2509369/how-to-validate-against-multiple-validation-groups) – Sumit Kapadia Jul 18 '13 at 11:25
  • I think the linked Post is a better solution than duplicating validation markup – Mick Jun 04 '15 at 03:31

1 Answers1

31

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

Paolo Tedesco
  • 55,237
  • 33
  • 144
  • 193
  • Good Solution.. Definitely solves the issue..But is it not possible to assign multiple groups to a validation control ? – Ananth Mar 14 '11 at 08:06
  • 2
    No it is not possible but you can call Page.Validate("groupOne"); Page.Validate("groupTwo"); from code behind. – Ásgeir Gunnar Stefánsson Apr 10 '14 at 17:27
  • 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. – user1566694 Jul 16 '18 at 15:21