• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Checking for " "

Explorer ,
Dec 26, 2006 Dec 26, 2006

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

422

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 26, 2006 Dec 26, 2006

Copy link to clipboard

Copied

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))>
OR
<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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 26, 2006 Dec 26, 2006

Copy link to clipboard

Copied

Ian,

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

appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 26, 2006 Dec 26, 2006

Copy link to clipboard

Copied

Why not use a validation script in javacript like the one offered from
Yaromat?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 26, 2006 Dec 26, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

Use cfform and cfinput. With the validate, mask, and range attributes, you can control what gets sent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 27, 2006 Dec 27, 2006

Copy link to clipboard

Copied

LATEST
Why not use a validation script in javacript like the one offered from
Yaromat?

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation