Skip to main content
A newer version of this page is available. .

ASPxClientEdit.SetErrorText(errorText) Method

Sets the error text to be displayed within the editor’s error frame if the editor’s validation fails.

Declaration

SetErrorText(
    errorText: string
): void

Parameters

Name Type Description
errorText string

A string value representing the error text.

Example

The code sample below demonstrates how you can perform a custom validation without using any predefined validation capabilities. Note that in this case, the ValidationSettings.EnableCustomValidation property should be set to true to show an error frame.

function OnAgeValidation(s, e) {
     var age = tbAge.GetText();
     if (age == null || age == "")
          return;
     var digits = "0123456789";
     for (var i = 0; i < age.length; i++) {
          if (digits.indexOf(age.charAt(i)) == -1) {
               tbAge.SetIsValid(false);
               break;
          }
     }
     if (tbAge.GetIsValid() && age.charAt(0) == '0') {
          age = age.replace(/^0+/, "");
          if (age.length == 0)
               age = "0";
          tbAge.SetText(age);

     }
     if (age < 18) {
          tbAge.SetIsValid(false);
          tbAge.SetErrorText('Age must be greater than or equal 18');
     }
}
See Also