Skip to main content

ASPxClientEdit.Validation Event

Allows you to specify whether the value entered into the editor is valid, and whether the editor is allowed to lose focus.


Validation: ASPxClientEvent<ASPxClientEditValidationEventHandler<ASPxClientEdit>>

Event Data

The Validation event's data class is ASPxClientEditValidationEventArgs. The following properties provide information specific to this event:

Property Description
errorText Gets or sets the error description.
isValid Gets or sets a value specifying whether the validated value is valid.
value Gets or sets the editor’s value being validated.


The Validation event is raised when it is required to validate the editor’s value on the client side (for instance, when a value is selected within an editor’s dropdown window, or an editor is about to lose focus, or an editor’s ASPxClientEdit.Validate method is called).

Handle the Validation event to test the editor’s edit value against custom validation criteria. If the entered value obtained via the ASPxClientEditValidationEventArgs.value property doesn’t meet your restrictions, you can prevent the editor from accepting this value (and losing focus) by setting the event parameter’s ASPxClientEditValidationEventArgs.isValid property to false. Then, end users will be forced to correct the edited value. For example, you can check whether the entered text contains only appropriate characters or a numeric value falls into a predefined range, etc.

Additionally, you can provide a text explaining why the validation has failed by assigning a descriptive text to the ASPxClientEditValidationEventArgs.errorText property. When the ASPxClientEditValidationEventArgs.isValid property is false, the specified text will be displayed within a specific message box.


The code sample below demonstrates how you can perform custom client-side validation to limit an permissible user age. For this purpose, the ASPxClientEdit.Validate event is handled.

function OnBirthdayValidation(s, e) {
     var birthday = e.value;
     var today = new Date();
     var msecPerYear = 1000 * 60 * 60 * 24 * 365;
     var years = (today.getTime() - birthday.getTime()) / msecPerYear;
     if(years < 14) {
          e.isValid = false;
          e.errorText = "You should be at least 14 years old.";
<dx:ASPxDateEdit ID="deBirthday" runat="server" Width="200px">
     <ClientSideEvents Validation="OnBirthdayValidation" />
          <RequiredField IsRequired="True" ErrorText="Birthday is required" />
See Also