Copy link to clipboard
Copied
I need help searching one of my form fields for any URL’s that are being passed to my list.
In the form field I am receiving content that looks like the following:
nhiccdppqfstupxo, <a href="http://.com/">abc</a>, abc, abc, http://.com/ abc, abc bz.
I need to use a RE function to check the form field for “http” and if it’s there abort the script so that it doesn’t send out to my list.
The problem I am having is that when I use CF functions I receive an error because of the quotes that are in the form field.
Anyone have any ideas as to how I can test for URL’s in a form field?
Thanks for any help that you can offer!
CTownNick
Copy link to clipboard
Copied
What function is giving you the error?
Copy link to clipboard
Copied
Dan I was using REfind but I got the answer in another post that I posted.
What I had to do was sent up a field and load the form field into it, like the following...
<cfset stringToSearch = '#form.xxx#'>
<p>
<cfset foundit = '#FindNoCase("http",stringToSearch)#'>
<cfif foundit gt 0>
<cflocation url="http://www.somewhere.com">
<cfabort>
</cfif>
If there is no URL in the form field the rest of the script runs.
Copy link to clipboard
Copied
Dan,
This is how I set the code up:
What I had to do was set up a field and load the form field into it, like the following...
<cfset stringToSearch = '#form.xxx#'>
(notice the single quotes, the code would not work if I used double quotes because there are double quotes in the URL that they entered, that was what was killing me in the first place using Refind!)
<p>
<cfset foundit = '#FindNoCase("http",stringToSearch)#'>
<cfif foundit gt 0>
<cflocation url="http://www.somewhere.com">
<cfabort>
</cfif>
If there is no URL in the form field the rest of the script runs.
Again thanks for taking the time to help me, I appreciated it very much!
Nick