form validation-client and server verifying your visitors form submissions jon brundage cf...
TRANSCRIPT
![Page 1: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/1.jpg)
Form Validation-Client and Server
Verifying your visitors form submissions
Jon Brundage CF developer/Section 508/web
accessibility [email protected]
![Page 2: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/2.jpg)
Why validate?
Safety protects your database and site
Better user experience Makes your site more professional
Saves time Less submits and page calls
![Page 3: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/3.jpg)
Two types of Validation
Client Via Scripting Javascript most
common May be defeated
by disabling JS in browser
Poses risks but convenient
Saves server load
Server Via CGI/ASP etc This discussion
focuses on the power of CF
Can’t be defeated by changes in browser settings
Safer but less convenient
![Page 4: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/4.jpg)
Client validation CFFORM Writes Javascript validation for you CFINPUT tag
http://www.macromedia.com/support/coldfusion/ts/documents/cfform_hotfix.htm hotfix for CFMX 6.1
Javascript Write your own Many free scripts available on the
Web http://webdeveloper.earthweb.com/webjs/ http://www.jsmadeeasy.com/ http://www.js-examples.com/js/ http://www.dynamicdrive.com/ (DHTML)
![Page 5: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/5.jpg)
Test for state of scripting on client
Inside the FORM tag, add a NOSCRIPT tag with a hidden form field <noscript> <input type="hidden" name="scriptOff"
value="scriptOff"> </noscript>
Use Isdefined(form.scriptOff) in action page with a CFIF tag to determine if you need to apply server side validation.
![Page 6: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/6.jpg)
Server validation
CF functions CF tags CF custom tags- developers exchange CF structures and arrays
![Page 7: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/7.jpg)
CF STRUCTURE
Contain variables called keysCreate with a CFSET statement <cfset formerrors=structnew()>
A structure with elements contained in it will have a count similar to query recordcount <cfif structcount(formerrors) gt "0">
![Page 8: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/8.jpg)
CF STRUCTURE cont.
Structures may be looped. <cfloop collection=#formerrors#
item="ErrorType"> <ul class="list"> <li style="color: ##FF0000;"> #formErrors[errorType]# </li> </ul> </cfloop>
![Page 9: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/9.jpg)
Using a structure to hold errors
<cfset formerrors=structnew()> as errors encountered, add to structure
<cfset temp=structinsert(formerrors,"ErroruserFirst","You failed to enter your first name." ,"yes")>
At the end of processing form errors, display by looping over the structure:
<cfloop collection=#formerrors# item="ErrorType"> <ul class="list"> <li style="color: ##FF0000;"> #formErrors[errorType]# </li> </ul> </cfloop>
![Page 10: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/10.jpg)
Make use of CF functions
IsNumeric Verify numeric fields
Findoneof Look at characters
And others! Use you creativity.
![Page 11: Form Validation-Client and Server Verifying your visitors form submissions Jon Brundage CF developer/Section 508/web accessibility Jonwind@windcompany.com](https://reader036.vdocument.in/reader036/viewer/2022082611/56649e2a5503460f94b18990/html5/thumbnails/11.jpg)
THANK YOU
Remember, CF has many tools at your disposal.Have fun, be creative and don’t worry too much about “being right”Many ways to solve problems.Questions/comments- [email protected]