[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'StdCtrls' (#lcl)

# TCustomEdit.NumbersOnly

Indicates if the edit control accepts numeric values only.

## Declaration

Source position: stdctrls.pp line 868

`public property TCustomEdit.NumbersOnly : Boolean read GetNumbersOnly write SetNumbersOnly default False;`

## Description

NumbersOnly is a Boolean property which controls whether Text is limited to characters which represent numeric digits. The default value for the property is False, and allows any character valid for the type to be entered. When set to True, only the characters '0'..'9' are accepted in Text. '+', '-', ',', and '.' are not numeric digits.

Changing the property value causes the widgetset class to be notified when a handle has been allocated for the control.

NumbersOnly is used in CreateParams to include the ES_NUMBER edit style in the creation parameters for the control when set to True.

NumbersOnly is not supported on all platform for the LCL; GTK 2 does not support the property.

Versions of Windows prior to Windows 95 did not enforce the ES_NUMBER style flag. It could be specified, but still allowed any value to be manually entered into the edit control. Some version of Windows allowed copy (Ctrl+C) and paste (Ctrl+V) to be used to insert non-numeric values - even when NumbersOnly is set to True.

For inputs that require both numeric and punctuation digits, use one of the keyboard event handlers like OnKeyPress or OnKeyDown to filter values as they are entered into a control. Or, use TMaskEdit which supports using an edit mask for the input values.

Remark: | NumbersOnly is not supported for the GTK2 or GTK3 widgetset.

## See also

TCustomEdit.Text |  | The text displayed and edited for the control.
TCustomEdit.CreateParams |  | Ensures the required creation parameters are set for handle creation.
TWinControl.OnKeyPress |  | Event handler signalled for character data entered by the user.
TWinControl.OnKeyDown |  | Event handler signalled for key down keyboard events.
TMaskEdit |  | TMaskEdit is an Edit box with characters masked out to avoid unauthorized reading.