Skip to main content
Known Participant
July 6, 2006
Question

CFFORM Validation onServer with disabled JavaScript

  • July 6, 2006
  • 2 replies
  • 1041 views
I am using cfform with validateat="onsubmit,onserver" to catch issues for JavaScript-enabled users right away, and to catch issues for non-JavaScript-enabled browsers on the server. However, on the server side, the default error message generated by CF has a link to go "back" to fix the form, but the link is coded in JavaScript!

Doesn't work very nicely for my app since the only users who would get this page would not have JS enabled. Is there any way to customize that default "back" link? (i.e., is there a template in CF admin?)
    This topic has been closed for replies.

    2 replies

    Legend
    February 1, 2013

    I wrote a tutorial on this many years back and revised it in 2010. It still applies... http://tutorial192.easycfm.com/index.cfm?fuseaction=tutorial&tutorialID=192

    Known Participant
    February 1, 2013

    Dan/Steve,

    Thank you for the responses.  I don't make a habit of using validateon.  I want to use it for a demo with a lot of input fields and didnt want to code all the validateat, rather use the built in features for demo purposes.  Writing the validation in the cfm seems lengthy.  Which brings up another question.  What is wrong with using:

    validateat="onsubmit,onserver"

    It seems like it will validate using javascript and if javascript is disabled, it will go to the built in validate process in coldfusion on the server.  Why write your own validation inside the cfm and duplicate the functionality?  I know it is cleaner to stay on the current page and show errors, and it is harder to customize, but for simple validation, why not?

    Legend
    February 1, 2013

    My experience is that the CF validation is very remedial and most real applications require much more. And as you found, the CF native server side validation still requires client side scripting enabled and relying on the BACK button opens its own can of worms. For a demo app or prototyping, you're probably fine using native CF validation. For production level apps, you're probably going to find it too limiting.

    Client side validation is primarily for a clean user experience. Server side validation is for application security. You should get into a habit of doing both.

    Known Participant
    February 1, 2013

    Anyone?  I am wanting to customize this page also.  Any ideas?

    Inspiring
    February 1, 2013

    My approach would be to have the form submit to the same page that contains it.  Then, when a form has been submitted, run validation code that you wrote yourself.  If the form fails validation, display the appropriate information, including the form.

    This way, the user doesn't have to go back anywhere.