CFIF question

Posted on 2013-09-19
Medium Priority
Last Modified: 2013-09-19
I'm sure this is really easy, probably some change which I don't know about, but here goes...

I have a home-grown CMS system that's worked GREAT for me these past 9 years.  Of course, it's gone through many upgrades over the years, but recently a CFIF statement issue arose.  

Over the years, I've used both FCK Editor and TinyMCE WYSIWYG textareas. With these, as many of you know, they automatically populate the textarea with this:


Open in new window

If the user doesn't enter anything into the editor box, I don't want this code written to the database, so, I had the following CFIF identify and remove this code:

<cfif form.mytext eq '<p>&nbsp;</p>'><cfset form.mytext = ''></cfif>

Open in new window

Unfortunately, this stopped working (ANNOYING!!!)  I tried 'contains' instead of equal, but obviously that doesn't work if they have this code anywhere in their content.  I tried 'contains', then tried to trim off the first 13 characters...THEN see if there was anything in the field, but thought that was dumb, so I figured I'd post this as there was probably some change I haven't come across yet.

Any idea why this would have stopped working and what I should be using to catch and remove this code?
Question by:StellaBob
  • 2

Accepted Solution

reiters earned 2000 total points
ID: 39506063
Without being able to see the data and code I can only guess that there is some kind of whitespace you are not seeing.  If you wrap trim around it, you will remove any whitespace before and after.  Keep the "eq" so it doesn't mess with real input that simply contains the text you are testing for.

<cfif trim(form.mytext) eq '<p>&nbsp;</p>'><cfset form.mytext = ''></cfif>

Author Closing Comment

ID: 39506071
OK...you're the coolest!!!  I thought about spaces, but wasn't seeing ANYTHING before or after this.  But when I added the trim...ding, ding, ding...it worked!!!

Thank you very much.  I knew it would be something easy, but sometimes we are too close to see.  You made my day!!!

Expert Comment

ID: 39506123
Glad I could help.

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question