Hey. First of all, you have to release ValidationGroup = "ContactGroup" from the button, because in this case the verification group will first trigger the validation on the page, then the OnClientClick event containing the validation function that will trigger the validation of the page again.
Then you must pass the ContactGroup verification group to the Page_ClientValidate () function so that it knows which controls to check, because just calling Page_ClientValidate () will check all the controls regardless of their verification group (and can display more than one verification message times, depending on how many validation groups you have).
In short, do something like this:
function validate() //javascript function { if (typeof(Page_ClientValidate) == 'function') { var isPageValid = Page_ClientValidate('ContactGroup'); if(isPageValid) { //your custom code } } } <asp:textbox id="txtMyBox" runat="server"/> <asp:requiredFieldValidator Id="rfv1" runat="server" ControlToValidate="txtMyBox" ValidationGroup="ContactGroup" ErrorMessage="Bad!"/> <asp:Button ID="btn1" runat="server" OnClientClick="validate()" Text="button"/> <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" ShowMessageBox="true" ShowSummary="false" ValidationGroup="ContactGroup" />
TestSubject09 Jan 18 '10 at 15:00 2010-01-18 15:00
source share