views:

12

answers:

1

I have two validation groups on a form (we will call them VG1 & VG2). I have the following code:

<asp:TextBox ID="textbox1" runat="server" ValidationGroup="VG2"  />  
<asp:RequiredFieldValidator Text="*" ForeColor="#C301B9" ID="RequiredFieldValidator1" runat="server" ErrorMessage="My error message" ControlToValidate="textbox1" ValidationGroup="VG2" />

When this control has focus and I hit enter the validation summary displays the validation error messages for VG1.

VG1 fields are not visible (set via JS). I think I may need to also disable VG1 validation group summary.

Any help with this would be appreciated.

+1  A: 

Hitting enter when in the text box is probably submitting the form or doing the equivelent of clicking some button that is in the VG1 validation group. If you put everything in VG2 within a Panel control and set the DefaultButton property on the panel to be a button in VG2 then hitting enter in the text box will no longer fire the validators in VG1. If you are simply hiding controls vai javascript remember they are still there on the page and their actions can still be triggered.

Ben Robinson
Thanks for this it makes sense, it has been a while since I have done web development and I was looking for the default button on the actual controls.
Burt