Validation is a runtime check for the validity of user-entered data, such as a social security number or date. The TextField and Text Area components, both found on the Form palette tab, can be validated by a script when text is entered into them. If the user enters inappropriate data, a dialog box appears with a message explaining what data is expected in this field.
Validation is handled by a JavaScript file called validate.js. You should never need to edit this file directly.
To set up a TextField or Text Area component for validation, perform the following steps:
Select the component's Validation property.
Select one of the following validation types from the drop-down list:
Validation Type
|
Description
|
Example of Valid Data
|
(none)
|
No validation. This is the default.
|
anything
|
Integer
|
Positive or negative integer.
|
-4, 0, 4, 44, 444
|
PositiveInteger
|
Integer greater than or equal to zero.
|
0, 4, 44, 444
|
Number
|
Any real number.
|
-12.5, 0, 12.5, 1000000
|
Alphabetic
|
Alphabetic characters A-Z a-z, and spaces.
|
A man, a plan, a canal
|
CreditCard
|
Standard credit card number.
|
1234 5678 9012 3456
|
USPhone
|
10-digit US telephone number.
|
(123) 456-7890
|
InternationalPhone
|
International telephone number.
|
011 23 4 567 890
|
Email
|
Email address, like user@domain.
|
jefro@haven.com
|
SSN
|
A 9-digit social-security number.
|
123-45-6789
|
USDate
|
A date as mm/dd/yy or mm/dd/yyyy.
|
12/31/99
|
IntlDate
|
A date as dd/mm/yy or dd/mm/yyyy.
|
31/12/99
|
Year
|
A 2- or 4-digit integer.
|
99, 1999
|
Month
|
An integer between 1 and 12.
|
1, 2, 3
|
Day
|
An integer between 1 and 31.
|
1, 15, 31
|
StateCode
|
2-character US state code.
|
CA, NY, AK
|
ZIPCode
|
US ZIP or ZIP+4 code.
|
94043, 94043-1234
|
(Custom)
|
Custom validation.
|
|
If you choose (Custom), you must provide the JavaScript code for your custom validation in the Validation Expression property. (value >= 10) && (value <= 20)
If you want to only accept entries that contain the string `scape,' as in
Netscape, you could use the following expression:
value.indexOf("scape")!=-1
The application displays a generic warning message, which is defined in the
validate.js file, if the user enters invalid data. To change this error
message, edit the file and change the contents of the iCustom variable.
|