Skip to main content

ASPxClientEditValidationEventArgs.value Property

Gets or sets the editor’s value being validated.

Declaration

value: string

Property Value

Type Description
string

An object that represents the validated value.

Remarks

You can analyze the value property to provide custom-written client-side validation of an end user’s input. In an event handler, test this value against any required condition(s) to check whether it’s valid.

If the entered value is not valid, you can set the ASPxClientEditValidationEventArgs.isValid property to false. In this case, the value will not be accepted by the validated editor and an error text specified by the ASPxClientEditValidationEventArgs.errorText property will be displayed within the editor’s error frame. Otherwise, you may correct the entered value manually by setting the value property and leaving the ASPxClientEditValidationEventArgs.isValid value set to true. In this case, the corrected value will be written to the editor being validated.

Example

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;
     if(!birthday)
          return;
     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" />
     <ValidationSettings>
          <RequiredField IsRequired="True" ErrorText="Birthday is required" />
     </ValidationSettings>
</dx:ASPxDateEdit>
See Also