2 Replies Latest reply on Oct 12, 2006 3:16 PM by Newsgroup_User

    Form validation

    nick.endgame
      Hi,

      I am working on a script made by somebody else who has since left the company. The page i am working on basically allows a user to enter details such as first and last name, username, password and email.

      This page is called adduser.cfm and obviously uses a form (html form not cf) and when the form is submitted the action property calls itself (adduser.cfm).

      When the page is reloaded, condition statements are used to verify data input from the form i.e.:

      <cfif Not IsLoaded("form.submit")>
      "display form like normal"
      <cfelse>
      "check form fields and output apropriate message"
      </cfif>

      Now, the problem i face is that if any of the form fields are not completed or not valid then i want to display an error message ideally without the form even being submitted, because using the structure of the code written above only allows the form to be displayed if the submit button hasn't been clicked. I want to check the details before the form is submitted.

      I know you can use cfform validation but i need to perform validation such as checking the email domain against an email already stored in a database and then displaying a message ideally next to the form field with the error.

      Also, If you are going to say use javascript, I have and it works perfectly, however, the IT director said "What if they have javascript disabled?". And this is the reason why i have a headache!!!!

      I hope i have explained my problem clearly. Also, I am afraid i cannot show any of the code.

      Thanks and i appreciate any response.
        • 1. Re: Form validation
          Level 7
          Here is how I do it:

          http://www.fordwebs.com/cfform.cfm

          --
          Ken Ford
          Adobe Community Expert
          Fordwebs, LLC
          http://www.fordwebs.com


          "nick.endgame" <webforumsuser@macromedia.com> wrote in message
          news:egm874$fqc$1@forums.macromedia.com...
          > Hi,
          >
          > I am working on a script made by somebody else who has since left the
          > company.
          > The page i am working on basically allows a user to enter details such as
          > first
          > and last name, username, password and email.
          >
          > This page is called adduser.cfm and obviously uses a form (html form not
          > cf)
          > and when the form is submitted the action property calls itself
          > (adduser.cfm).
          >
          > When the page is reloaded, condition statements are used to verify data
          > input
          > from the form i.e.:
          >
          > <cfif Not IsLoaded("form.submit")>
          > "display form like normal"
          > <cfelse>
          > "check form fields and output apropriate message"
          > </cfif>
          >
          > Now, the problem i face is that if any of the form fields are not
          > completed or
          > not valid then i want to display an error message ideally without the form
          > even
          > being submitted, because using the structure of the code written above
          > only
          > allows the form to be displayed if the submit button hasn't been clicked.
          > I
          > want to check the details before the form is submitted.
          >
          > I know you can use cfform validation but i need to perform validation such
          > as
          > checking the email domain against an email already stored in a database
          > and
          > then displaying a message ideally next to the form field with the error.
          >
          > Also, If you are going to say use javascript, I have and it works
          > perfectly,
          > however, the IT director said "What if they have javascript disabled?".
          > And
          > this is the reason why i have a headache!!!!
          >
          > I hope i have explained my problem clearly. Also, I am afraid i cannot
          > show
          > any of the code.
          >
          > Thanks and i appreciate any response.
          >


          • 2. Re: Form validation
            Level 7
            I know you can use cfform validation but i need to perform validation
            such as checking the email domain against an email already stored in a
            database and then displaying a message ideally next to the form field
            with the error.

            Also, If you are going to say use javascript, I have and it works
            perfectly, however, the IT director said "What if they have javascript
            disabled?". And this is the reason why i have a headache!!!!

            nick.endgame

            Welcome to form validation. Best practice form validation is always a
            two step process. You validate as much as you can on the client with
            javascript or other client side language. With the use of AJAX this can
            now incorporate server side logic with some effort.

            But no matter what you do on the client, you can not TRUST it. There
            many many ways that somebody can mess you up. You always re-validate on
            the server anything that you validated on the client for UI niceness.
            You may also add extra validation on the server that one is unable to
            easily incorporate into the client.

            Using the <cfform...> and other ColdFusion validataion tools just makes
            this easier to create, but any client side validation is still done with
            javascript. CF just creates the javascript auto-magically for you.