Validation on the Server and Client

You’ve seen <cfinput> used to validate on the server and on the client. So far we used one or the other, but it need not be an either/or proposition. In fact, <cfinput> supports the use of multiple validation types at once. All you need to do is specify the types delimited by commas.

So, to validate the UserID field using masks, client-side validation, and server-side validation, you could do the following:

<cfinput type="text"
         name="LoginID"
         maxlength="5"
         required="yes"
         mask="99999"
         message="A valid numeric ID is required!"
         validate="integer"
         validateAt="onSubmit,onServer">

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.