Validation of text fields

  • Thread starter Thread starter GaryB
  • Start date Start date
G

GaryB

Hi,

I am trying to validate a text field on a form to the NZ IRD number
format (two digits; hyphen; three digits; hyphen; three digits).

The following validation formula

format([IRD Number], ##-###-####)

generates the following syntax error:

-----------------
Error in Validation formula for "IRD Number" -- the Date Constant is
not valid. Make sure you have entered a valid date in the formula.
-----------------

The following validation formula

format([IRD Number], 12-345-678)

validates

--

(two hyphens) as true. I.e. it forces the hyphens, but doesn't force
the correct number of digits.

Where am I going wrong?

Thanks very much.

Rgds

GaryB
 
A validation formula must return True if the data is "good" and False if
it's not. Therefore, Format(), which is a text formatting function, does
work as a validation formula. Instead, you would need to perform text
parsing using Mid() and other functions to check whether each of the five
parts of the field meets your criteria. I personally wouldn't try to do that
with a formula -- too hard to debug -- but would use code in the Item_write
or Item_Send event handler instead.
 
Back
Top