how to validate fields
rcozens at pon.net
Fri Sep 29 11:14:44 CDT 2006
>I need to validate fields.. for example.. only enter numbers in some
>fields.. i need for example fields with format for example Q1.000.50
>How i can to put these automatic conditions in a field?
Validation of user field input is generally triggered by a
closeField, enterInField, or (for single line fields) returnInField
message; however character, security, and mask restrictions are
better enforced in keyDown frontScript handlers.
Common validation may include:
* Required field -- Cannot be empty
* Restricted length --Maximum number of characters
* Restricted height -- Maximum number of lines
* Numeric precision -- Number of characters right of the
* Numeric formatting -- Insert/allow thousands separators in numbers
* Specific format -- Date, time, number, currency
* Secure field -- User input is not displayed
* Full field -- Input length must = specified field length
* Auto entry -- Close field when input length = specified field length
* Field mask -- Input must be compliant with mask format
defined for the field
* Xref field -- Validate input as a key to a record or
existing in a table
* Restricted characters -- Digits only, alpha only, uppercase
only, disallowed characters,
low order characters only, positive numbers only,
Scritping and testing all these possibilities is not trivial; however
once in place -- and I'm still in the testing stage myself -- these
validation checks can be specified in a Data Dictionary and be
automatically enforced with no further scripting.
But there is another approach: design your application so field
validation is minimalized.
If the user selects a date from a calendar, she can _never_ enter an
invalid date. (Incorrect date, yes; but invalid, never.) Likewise
for times selected from a clock image.
If the user selects field input from a pull-down list instead of
typing, the input cannot be invalid (though it might be illogical
juxtaposed with other input).
If, in your example "Q1.000.50", the decimal points are constant, you
could have three user input fields ("Q1", "000", and "50") , validate
each field separately, and concatenate them between decimals to form
the working input.
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode