Share via


Format Input and Validate Data in a Text Box Sample

File: ...\Samples\Solution\Controls\TXT_EDT\Textbox.scx

This sample shows how to set text box properties to make it easy for a user to enter data in the required format.

Format

Property

Setting

Allow Only Digits

InputMask

999999999

Select On Entry

SelectOnEntry

.T.

All Uppercase

Format

!

Read-Only

ReadOnly

.T.

US Telephone Number

InputMask

(999) 999-9999

Password text

PasswordChar

*

Date Formatting

DateFormat

a number between 0 and 14

Validating Input

The following code in the Valid event of a text box prevents a user from leaving the text box if the letter "a" is in the text:

IF "a"$ THIS.Value
   #DEFINE MESSAGE_LOC "The text box value cannot contain the letter 'a'"
   MESSAGEBOX(MESSAGE_LOC,48+0+0)
   RETURN 0
ELSE
   RETURN .T.
ENDIF

See Also

Tasks

Solution Samples

Reference

Visual FoxPro Foundation Classes A-Z

Other Resources

Controls Solution Samples