wpf-7422-controls-and-libraries-data-editors-examples-how-to-implement-a-custom-validation-procedure.md
The following example shows how to handle the BaseEdit.Validate event to implement a custom validation procedure.
The image below shows the result:
<dxe:TextEdit x:Name="dxTextEdit"
ValidateOnTextInput="False"
Validate="dxTextEdit_Validate"/>
private void dxTextEdit_Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e) {
// e.Value - the processed input value
if (e.Value == null) return;
if (e.Value.ToString().Length > 4) return;
// Set the e.IsValid property to 'false' if the input value is invalid
e.IsValid = false;
// Specifies the error icon type
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information;
// Specifies the error text
e.ErrorContent = "User ID is less than five symbols. Please correct.";
}
Private Sub dxTextEdit_Validate(ByVal sender As Object, ByVal e As DevExpress.Xpf.Editors.ValidationEventArgs)
' e.Value - the processed input value
If e.Value Is Nothing Then Return
If e.Value.ToString().Length > 4 Then Return
' Set the e.IsValid property to 'false' if the input value is invalid
e.IsValid = False
' Specifies the error icon type
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information
' Specifies the error text
e.ErrorContent = "User ID is less than five symbols. Please correct."
End Sub