Skip to main content

ASPxClientEdit.GetIsValid Method

Gets a value that indicates whether the editor’s value passes validation.

Declaration

GetIsValid(): boolean

Returns

Type Description
boolean

true if the editor’s value passes validation; otherwise, false.

Example

The code sample below implements custom validation without using any predefined validation capabilities. Note that you should set the ValidationSettings.EnableCustomValidation property 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');
     }
}
<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" ClientInstanceName="tbAge">
     <ValidationSettings ValidateOnLeave="False" EnableCustomValidation="True">
     </ValidationSettings>
</dx:ASPxTextBox>

<dx:ASPxButton ID="btnValidate" runat="server" AutoPostBack="False" Text="Validate">
     <ClientSideEvents Click="OnAgeValidation" />
</dx:ASPxButton>
See Also