I wrote this as a general solution (can be used on all .NET websites).
You only need to add OnClientClick to the submit button.
//=================================================================== // Disable .NET validators for hidden elements. Returns whether Page is now valid. // Usage: // <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="DisableHiddenValidators()" /> //=================================================================== function DisableHiddenValidators() { for (var i = 0; i < Page_Validators.length; i++) { var visible = $('#' + Page_Validators[i].controltovalidate).is(':visible'); ValidatorEnable(Page_Validators[i], visible) } return Page_ClientValidate(); }
To use it, just include the javascript above and add the class OnClientClick="DisableHiddenValidators()"
to the submit button:
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="DisableHiddenValidators()" />
EDIT: The jQuery $(submitButton).click
did not work on iPhone / Android. I slightly modified the sample code.
If someone sees something wrong or possible improvements, please comment :)
source share