<cf_datavalidate> - PowerPoint PPT Presentation

About This Presentation
Title:

<cf_datavalidate>

Description:

cf_datavalidate Derrick Rapley. adrapley_at_rapleyzone.com. Maryland CFUG. October 8, 2002 ... To prevent bad data from being entered into the database ... – PowerPoint PPT presentation

Number of Views:11
Avg rating:3.0/5.0
Slides: 12
Provided by: derrick4
Category:
Tags: derrick

less

Transcript and Presenter's Notes

Title: <cf_datavalidate>


1
ltcf_datavalidategt
  • Derrick Rapley
  • adrapley_at_rapleyzone.com
  • Maryland CFUG
  • October 8, 2002

2
Agenda
  • What is cf_datavalidate?
  • Why use server-side validation?
  • How to use cf_datavalidate
  • Syntax
  • Displaying Error Messages
  • Using Custom Validation

3
What is cf_datavalidate?
  • cf_datavalidate is a custom tag that performs
    server-side data validation
  • Requires use of child tag cf_dataValidateItem
  • Easy to use
  • Minimizes the amount of code needed to perform
    validation
  • Keeps track of error messages
  • Handle custom validation

4
Why use server-side validation?
  • To prevent potential malicious attacks
  • To prevent bad data from being entered into the
    database
  • Client side validation is useless when JavaScript
    is turned off. (including CFFORM)

5
cf_datavalidate
  • cf_datavalidate is the parent tag
  • Must have end tag
  • Requires two parameters
  • OUTPUT (required) the variable you want the
    error messages stored in
  • TYPE (optional) the type of variable for
    OUTPUT, QUERY or STRUCTURE (default is QUERY)
  • ltcf_datavalidate output"qryErrors"
    type"structure"gt
  • ltcf_dataValidateItemgt
  • lt/cf_datavalidategt

6
cf_dataValidateItem
  • Must be encapsulated by cf_datavalidate
  • ltcf_dataValidate output"qryErrors"gt
  • ltcf_dataValidateItem type"required"
    valueform.FirstName" messageFirst Name is
    required"gt
  • lt/cf_dataValidategt
  • Parameters vary upon the TYPE of validation
  • TYPE and MESSAGE are required for all Types

7
cf_dataValidateItem - Types
  • Required
  • Numeric
  • SimpleValue
  • LenLT
  • LenGT
  • Range
  • Compare
  • Email
  • Space
  • Repex
  • 3of4
  • Date
  • DateCompare
  • DateRange
  • DateGT
  • DateLT

8
Displaying Errors
  • Depends on the specified TYPE in the parent tag
    cf_datavalidate
  • 2 ways to display the error messages
  • Query loop through the query of messages
  • Structure Re-display the form and show the
    error message associated with each field (a
    little more advanced and requires some form
    manipulation)

9
Displaying Errors - Query
  • The error messages are placed in a query that you
    can loop through
  • ltcf_dataValidate outputqryErrors type
    querygt
  • ltcf_dataValidateItem type"required"
    valueform.FirstName messageFirst Name is
    required"gt
  • lt/cf_dataValidategt
  • ltcfif qryErrors.RecordCountgt
  • ltcfoutput queryqryErrorsgt
  • qryErrors.messageltbrgt
  • lt/cfoutputgt
  • ltcfabort
  • lt/cfifgt

10
Displaying Errors - Structure
  • Requires form manipulation
  • Form needs to be included in the template that
    does the validation
  • The parameter FORMFIELD is required in the child
    tag ltcf_dataValidateItemgt
  • ltcf_dataValidate outputqryErrors type
    structuregt
  • ltcf_dataValidateItem type"required"
    valueform.FirstName messageFirst Name is
    required formfieldFirstNamegt
  • lt/cf_dataValidategt

11
Including Custom Validation
  • Include the custom scenario inside
    cf_datavalidate
  • ltcf_dataValidate outputqryErrors type
    querygt
  • ltcf_dataValidateItem type"required"
    valueform.FirstName messageFirst Name is
    required"gt
  • ltcfif form.company NEQ ACME Anvilsgt
  • ltcf_dataValidateItem typecustom
    messageCustom Errorgt
  • lt/cfifgt
  • lt/cf_dataValidategt
Write a Comment
User Comments (0)
About PowerShow.com