JavaScript Editor js editor     Web development 

Main Page

The text box is a basic control that makes it possible for users to add or edit data stored in a non-memo field in a table.

The following table describes some of the tasks you can perform with text boxes by setting the appropriate properties.

Property Action

SelectOnEntry Property

Select all text when user enters the text box using the keyboard.

InputMask Property

Determine values that can be typed in the text box.

Format Property

Determine how values are displayed in the text box.

Value Property

Reference or change the text displayed in the text box in code.

ControlSource Property

Store the value displayed in the text box in the Value property and in the variable or field specified by the ControlSource property.

AutoComplete Property

Display a dynamic list of previously entered values to chose.

AutoCompTable Property

Specify the table that populates the dynamic list for the text box.

AutoCompSource Property

Specify a field in the auto-completion table to associate with the text box.

The file in the Visual FoxPro ...\Samples\Solution directory contains examples of how to use text boxes. After you open, in the tree view, click Controls, then Text boxes.

Date Values in Text Boxes

Text boxes have several properties that make it easy for users to enter date values. The following table lists properties you can set to control how dates can be entered in text boxes.

Property Description


Sets whether the first two digits of the year are displayed or not.


Formats the date in the text box to one of fifteen predetermined formats, such as German or Japanese.


Sets StrictDateEntry to 0 - Loose. This makes it possible for a user to enter dates in more flexible formats than the default 99/99/99.

Validating Data in Text Boxes

You can check or verify values in text boxes by including code inside the Valid event for the text box. If the value in the text box is invalid, return False (.F.) or 0 from the code you use to evaluate the text box value in the Valid event. If the Valid event returns False (.F.), Visual FoxPro displays the message "Invalid input".

The control does not lose focus if the Valid event returns False (.F.) or 0.В В В 

For example, suppose you have a text box in which a user can type an appointment date. You can check that the date has not already passed by including the following example code in the Valid event for the text box:

В Copy Code
   = MESSAGEBOX("You need to enter a future date",1)

If you want to display your own message, include the WAIT WINDOW command or the MESSAGEBOX(В ) function in the Valid event code and return 0. For more information, see WAIT Command and MESSAGEBOX(В ) Function.

See Also

JavaScript Editor js editor     Web development