Ignore .NET validators if element is hidden (display: none)

I wrote this as a general solution (can be used on all .NET websites).

You only need to add an 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, simply include the above javascript and add the class OnClientClick="DisableHiddenValidators()" to the submit button:

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="DisableHiddenValidators()" />

EDIT: jQuery $(submitButton).click function didn't work on iPhone/Android. I have changed the sample code above slightly.

If anyone see anything wrong or possible improvements please comment :)