Skip to main content
March 23, 2010
Question

Empty Entry Prevention

  • March 23, 2010
  • 2 replies
  • 604 views

Essentially, here is what I want to happen:

Instead of making it a requirement to enter data into a textbox (cfinput), I want to make it so if there is an empty textbox, the entire form will not be entered into the database, but will act as though it were submitted (I know this sounds strange, but this is actually what needs to happen).

This topic has been closed for replies.

2 replies

Inspiring
March 24, 2010

What's the part you are having trouble with?

March 24, 2010

Thank you both for your quick repsonses, however I have solved the problem.  What I did was put CFIF statements around each query stating that if the textbox was empty, it wouldn't run the query script.

ilssac
Inspiring
March 24, 2010

Ok, good.  That was pretty much what we where guiding you towards.

But separate if statements around each <cfquery...> block?  Are they all testing the same form field?  If so, wouldn't it be easier to have one at the beginning of the file that tests the field and then prevents the processing of any of the database code?  That's what I would have tried for.  I like writing less code whenever possible.

ilssac
Inspiring
March 23, 2010

Submit the form, then on the action page validate the values according the the business rules and chooe the appropiate branch for what happens to the data from two or more appropiate choices.