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

checking field content

Explorer ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Hi,

I would like to be able to tell if a field contains a string such as "http" or "www".

How can i do this?

Thanks.
TOPICS
Advanced techniques

Views

548

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
New Here ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

<cfif FindNoCase('www',myField) OR FindNoCase('http',myField)>

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
Engaged ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Or even better

<cfif reFindNoCase('www|http',myField)>

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
Engaged ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Or even better than that
<cfif listFindNoCase('www,http',myField)>

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
New Here ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

or did you mean via SQL?

WHERE myField LIKE '%www%' OR myField LIKE '%http%'

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 ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

Superb. Thank you both very much.

By the way, i meant by CF not SQL.

Thanks again.

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 ,
Jan 08, 2007 Jan 08, 2007

Copy link to clipboard

Copied

You sure you actually got the right answer? Based on your original question, I don't think so.

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 ,
Jan 10, 2007 Jan 10, 2007

Copy link to clipboard

Copied

Thanks for the post Dan. You're right, I didn't get the right answer based on my original question. Just done some testing.

My own fault, didn't explain my aim properly. I would like to be able to submit a form textarea and check the content of the textarea for instances of strings such as "www" and "http". I am actually trying to stop people from entering links and html in form fields.

I hope this is a more specific post.

Thanks.

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 ,
Jan 10, 2007 Jan 10, 2007

Copy link to clipboard

Copied

LATEST
The function you want to use is called contains. Usage is described in the cfml reference manual. If you don't have one, the internet does.

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