FMX.Edit.TEdit.OnValidating

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property OnValidating: TValidateTextEvent read GetOnValidating write SetOnValidating;

C++

__property OnValidating;

Properties

Type Visibility Source Unit Parent
event published
FMX.Edit.pas
FMX.Edit.hpp
FMX.Edit TEdit

Description

Occurs when you are entering symbols or when focus shifts away from this edit control.

FMX.Edit.TEdit.OnValidating inherits from FMX.Edit.TCustomEdit.OnValidating. All content below this line refers to FMX.Edit.TCustomEdit.OnValidating.

Occurs when you are entering symbols or when focus shifts away from this edit control.

Write an OnValidating event handler to immediately validate any edits while the user is entering information into the edit control. The OnValidating event handler can verify the supplied text and, if it is not acceptable, return an error or warning message.

Example

To clarify, consider the following scenario: an application provides a text edit box designed to enter an email address. If the user enters the blank character or the "@." substring, the OnValidating event handler displays the exclamation icon next to the edit control. This icon informs the user that the current symbols are not acceptable for the email address.

Note: Initially, the exclamation icon is invisible. The OnValidating event handler sets the TImage.Visible property to True, if an input error occurs.

OnValidating.png

For this scenario, you can implement the following OnValidating event handlers:

Delphi:

procedure TForm1.Edit1Validating(Sender: TObject; var Text: string);
begin
  Image1.Visible := Text.Contains(' ') or Text.Contains('@.');
end;

C++Builder:

void __fastcall TForm1::Edit1Validating(TObject *Sender, UnicodeString &Text) {
	Image1->Visible = ContainsStr(Text, " ") || ContainsStr(Text, "@.");
}

Note: To process the user's input, these code snippets use:

See Also