How can I validate the length of a text input?

Sometimes you need to check that a form input has a text string of a specific length, or is not longer or shorter that some specific values.

You can do this very simply by adding an entry to the Field Class box input element:

validate['length[min,max]']

Where 'min' and 'max' are the minimum and maximum length allowed. For example:

validate['length[5,8]']

To set an exact length, set 'min' to the length and set 'max' to -1. For example:

validate['length[12,-1]']
 
Category: CFv4 Validation

Comments:

You need to login to be able to post a comment.