Wednesday 11 June 2014

Enable / Disable Asp.Net Validation

<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="txt1" ErrorMessage="*" ValidationGroup="1"></asp:RequiredFieldValidator>

<asp:TextBox ID="txt2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv2" runat="server" ControlToValidate="txt2" ErrorMessage="*" ValidationGroup="1"></asp:RequiredFieldValidator>

<asp:TextBox ID="txt3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv3" runat="server" ControlToValidate="txt3" ErrorMessage="*" ValidationGroup="1"></asp:RequiredFieldValidator>
            <br />

<asp:Button ID="btn" runat="server" CssClass="btn" Text="Save" ValidationGroup="1" OnClientClick="ValidatorEnable(rfv2, false);" />



Use this function to disable/Enable validation

ValidatorEnable(Id of Validator, Enable or Disable (true/false))

e.g.
 ValidatorEnable(rfv2, false)


No comments:

Post a Comment