anothers issue, I am working from a code I didn't create but now have to modify; The end result of my problem is to make sure that only three numbers are entered for area code, three for phone prefix and four numbers in the last field.
Having hard time, never used CF before and need syntax to validate three fields (form.phone, form.phone2, form.phone.3) to be numeric and contain the correct number of numbers.
- <META HTTP-EQUIV="Refresh"
-
CONTENT="5; URL=http://xxx/index.php">
-
-
-
<cfif IsDefined('form.send_email')>
-
<cfset errorMsg = ''>
-
-
<cfif Len(Trim(form.name)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter your name<br/>'>
-
</cfif>
-
<cfif Len(Trim(form.email)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter your email address<br/>'>
-
<cfelseif form.email DOES NOT CONTAIN '@' OR form.email DOES NOT CONTAIN '.'>
-
<cfset errorMsg = errorMsg & '- Please enter a valid email address<br/>'>
-
</cfif>
-
<cfif Len(Trim(form.comments)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter your comments or questions<br/>'>
-
</cfif>
-
<cfif Len(Trim(form.phone)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter 3 digit area code<br/>'>
-
</cfif>
-
<cfif Len(Trim(form.phone2)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter the first three numbers of your phone number<br/>'>
-
</cfif>
-
<cfif Len(Trim(form.phone3)) EQ 0>
-
<cfset errorMsg = errorMsg & '- Please enter the last four numbers of your phone number<br/>'>
-
</cfif>
-
-
-
<cfif Len(Trim(errorMsg)) GT 0>
-
<cfset urlString = URLEncodedFormat(errorMsg)>
-
<cfset valueString = "name=#URLEncodedFormat(form.name)#&company=#URLEncodedFormat(form.company)#&email=#URLEncodedFormat(form.email)#&phone=#URLEncodedFormat(form.phone)#&comments=#URLEncodedFormat(form.comments)#">
-
<cflocation url="#cgi.HTTP_REFERER#?email_error=1&error_msg=#urlString#&#valueString#">
-
<cfelse>
-
<cfmail to="#form.to_email#" from="#form.email#" subject="#form.subject#">
-
An email has been submitted to learn more from the following person:
-
-
Name: #form.name#
-
Company: #form.company#
-
Email: #form.email#
-
Phone: #form.phone# #form.phone2# #form.phone3#
-
-
Comments: #form.comments#
-
</cfmail>
-
<cflocation url="http://xxx/ThankYou.htm">
-
</cfif>
-
<cfelse>
-
<p style="font:bold 12px Verdana, Arial, Helvetica, sans-serif; color:red;">You do not have access to view this page.</p>
-
</cfif>
A bounus would be to know whow to get the errors to display in a pop up; like I said this is someones code before I was hired and I only new basic HTML until this job; but when it validates and there is an error the error message is in the address bar???
Thank you,
CF