6 Replies Latest reply on Dec 27, 2006 7:52 AM by Newsgroup_User

    Checking for " "

      Hello everyone. I'm sure there is a simple answer to my dilemma but so far it has evaded me. Here is my problem:

      I have a forum with 3 inputs on it that are given me problems. Here they are:
      One text area input (html) - Work Description
      Two text inputs (html). - Hours worked & Minutes Worked.

      I also have one html "Submit" button
      and one html "Select" input as well.

      An insert statement is utilized everytime someone clicks the submit button. An update function is also utilized everytime

      the submit button is clicked as well. What I am trying to do is code a condition that will make the insert statment NOT fire if

      the individual does not have a value filled out for hours worked, minutes worked, or description. I still need the other

      cfqueryto work when the submit button is clicked (an update function fires when submit is clicked as well). I need the

      update query to still work as it will be updating a record to reflect the change in the select input. I want the insert statement

      to be disabled/not work when the text area, and text inputs do not have a value for them. Is this possible using html inputs

      or do they have to be cf inputs? I am editing a preexisting page so my previous efforts to turn these html inputs to cf inputs

      have met with great resistance. Any help would be greatly appreciated. Thank you

        • 1. Re: Checking for " "
          Level 7
          Thank you

          I was too, I believe you are asking how to do something or not do
          something if certain fields do not contain a value. If so, the way I
          usually do this is this way. This checks that at least one non-white
          space character exists in the field. Modify as desired to further
          validate the field.

          <cfif len(trim(form.aField))>
          <cfif len(trim(form.aField)) GT 0>

          There are also ways that this can be built in with <cfinput...> tags OR
          CF's hidden form field validation tools. But as these primarily deal
          with client side validation, one should always double check with server
          side validation similar to above.
          • 2. Re: Checking for &quot; &quot;
            Level 7
            Why not use a validation script in javacript like the one offered from

            • 3. Re: Checking for &quot; &quot;
              VinceMan Level 1
              Please pardon my lack of knowledge. Where can I find this javascript code that you speak of? What is this bit of javascript

              code supposed to do? I still need activity to happen on the server side when the submit button is pressed. The update

              statement still needs to work but the insert statement needs to be "halted" upon clicking the submit button. Thank you for the

              feed back I really appreciate it. Any additional help you could give me would be awesome.
              • 4. Re: Checking for &quot; &quot;
                VinceMan Level 1

                Thanks for your input. I'm going to try things your way and see where I end up. This will work great for checking the text

                area input. I do have one additonal task/problem to tack onto that though. If my boss wants me to have a default of "00" in

                the hours and minutes input, how do I have Coldfusion check to see if the current value entered into those text inputs is

                different than the default value (long run on sentence I know). Basically if I set the default to "00" in each text input for hours

                and minutes, I want the insert statement for those two inputs to NOT fire if the current value of the two text inputs is "00".

                I'm assuming that this is more client side validation? Correct me if I'm wrong. Thanks again. Any help would be greatly

                • 5. Re: Checking for &quot; &quot;
                  Dan Bracuk Level 5
                  Use cfform and cfinput. With the validate, mask, and range attributes, you can control what gets sent.
                  • 6. Re: Checking for &quot; &quot;
                    Level 7
                    Why not use a validation script in javacript like the one offered from

                    Because I can turn off JavaScript in my browser, which then turns off
                    the javascript validation and if you are not double checking the
                    validation on the server side, I can really mess up your data either
                    unintentionally or intentionally.

                    JavaScript is client side User Interface. Server side is CYA make sure
                    the data is clean before I commit it.