Copy link to clipboard
Copied
I have a form with mutiple text fields for user to enter email addresses. I don't want them to enter the duplicate emails so created two lists here
Existing_EmailList: list all emails in the table.
Current_EmailList: all from the form (included from table and new email just enter)
I've tried to do ListContains, and Listfind but none of them work. Can you help?
<cfset Existing_EmailList = valuelist(getCurrentEmail.email, ',') />
test@test.com, yes@yes.com, no@no.com
<cfset Current_EmailList = arguments.email />
test@test.com, yes@yes.com, no@no.com,no@no.com,one@one.com
<!---<cfif ListContains(Existing_EmailList, #Current_EmailList#)>--->
<cfif Listfind(Existing_EmailList, #Current_EmailList#)>
<cfset duplicate = true>
<cfelse>
<cfset duplicate = false>
</cfif>
Thanks
Copy link to clipboard
Copied
I suggest a different approach altogether. Query the database for the email submitted to see if it already exists.
Copy link to clipboard
Copied
How come the longer list is coming in as an argument? What is the point of one list completely including the other? Why not just find out whether the new e-mails are in the database as Dan suggests? It seems odd to be comparing two lists.