How to: Validate a Particular Editor
To validate a particular editor you can use one of the following ways.
- Set the ValidationSettings.ValidateOnLeave property to true (the default value) to automatically validate an editor after its value has been changed.
Call the editor’s client-side ASPxClientEdit.Validate method.
The code sample below demonstrates validating a single editor via a script.
<dx:ASPxLabel ID="lbl" runat="server" Text="E-mail:"> </dx:ASPxLabel> <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" ClientInstanceName="tbEmail"> <ValidationSettings ValidateOnLeave="False"> <RequiredField ErrorText="E-mail is required" IsRequired="True" /> </ValidationSettings> </dx:ASPxTextBox> <dx:ASPxButton ID="btn" runat="server" Text="Submit" AutoPostBack="False" CausesValidation="False"> <ClientSideEvents Click="function(s, e) { tbEmail.Validate(); }" /> </dx:ASPxButton>
Call the editor’s server-side ASPxEdit.Validate method.
<dx:ASPxLabel ID="lbl" runat="server" Text="E-mail:"> </dx:ASPxLabel> <dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px"> <ValidationSettings ValidateOnLeave="False"> <RequiredField ErrorText="E-mail is required" IsRequired="True" /> </ValidationSettings> </dx:ASPxTextBox> <dx:ASPxButton ID="btn" runat="server" Text="Submit" onclick="btn_Click" CausesValidation="False"> </dx:ASPxButton>