• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Adding JavaScript to Your Forms > Implementing Data Validation

Implementing Data Validation

Another aspect of checking a user's form submission is data validation. When you enforce a required field, you're simply checking to see whether something was typed into the field (in the case of text and password fields) or whether a choice was made in the field (in the case of check boxes, radio buttons, and select lists). Data validation takes the process a step further in that you actually check what was typed in to make sure it adheres to a particular format. For example, a Social Security number has to be of the form xxx-xx-xxxx, where each x represents a digit 0 through 9. You can ask ColdFusion to add JavaScript to your forms to validate data on the following kinds of fields:

  • Dates (mm/dd/yyyy) and European formatted dates (dd/mm/yyyy)

  • Times (hh:mm:ss)

  • Numbers (integers, floating-point decimal numbers, and ranges of values)

  • Telephone numbers (xxx-xxx-xxxx)

  • Zip codes (xxxxx or xxxxx-xxxx)

  • Credit card numbers (verification through the mod10 algorithm, a standard procedure used to verify the authenticity of a credit card number)

  • Social Security numbers (xxx-xx-xxxx)

  • Any field whose input has a pattern you can express using a regular expression


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint