I am very green on CF and CFM files and have this code below; I need to help for the error messages to "pop up" in a new window or display on the body of the page so anyone filling out the form knows that an error occurred with the entry trying to be submitted.
Any help would be awesome!
mailer.cfm: (VALIDATE/SEND)
Expand|Select|Wrap|Line Numbers
- <META HTTP-EQUIV="Refresh"
- CONTENT="5; URL=http://whoscalling.com/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 about FleetQUEST360 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://www.whoscalling.com/ThankYou_fleetquest360.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>
FORM:
Expand|Select|Wrap|Line Numbers
- <input type="hidden" name="to_email" value="incomingleads@xxx.com">
- <input type="hidden" name="subject" value="Sales Support">
- <form action="http://xxx.com/mailer.cfm" method="post" class="style15">
- <table border="0" cellpadding="3" cellspacing="0" class="contact-form">
- <tr>
- <td>NAME:<br />
- <input name="name" type="text" class="text" value="" size="25" /></td>
- <td rowspan="4"><div align="right"><a href="javascript:makeClickToTalk('https://xxx.com/','5555555555','clickDemo')" target="_top"><img src="CLICK.gif" alt="Click To Talk" name="clicktotalk" width="200" height="134" border="0" class="custombutton" id="clicktotalk" style="" /></a></div></td>
- </tr>
- <tr>
- <td>COMPANY:<br />
- <input name="company" type="text" class="text" value="" size="25" /></td>
- </tr>
- <tr>
- <td> BUSINESS:<br />
- <select name="Business" input type="option" name="name" value="">
- <option value=""> </option>
- <option value="ad agency">Ad Agency</option>
- <option value="auto dealership">Auto Dealership</option>
- <option value="education">Education</option>
- <option value="financial">Financial</option>
- <option value="health/fitness center">Health/Fitness Center</option>
- <option value="home builders/contractors">Home Builders/Contractors</option>
- <option value="home improvement">Home Improvement</option>
- <option value="insurance">Insurance</option>
- <option value="land developer">Land Developer</option>
- <option value="legal">Legal</option>
- <option value="medical">Medical</option>
- <option value="motorcycle dealer">Motorcycle Dealer</option>
- <option value="multi-housing industry">Multi-Housing Industry</option>
- <option value="publisher">Publisher</option>
- <option value="real estate">Real Estate</option>
- <option value="retail">Retail</option>
- <option value="rv dealer">RV Dealer</option>
- <option value="sports & entertainment">Sports & Entertainment</option>
- <option value="transportation">Transportation</option>
- <option value="travel">Travel</option>
- <option value="watercraft dealer">Watercraft Dealer</option>
- <option value="other">Other</option>
- </select></td>
- <td></td>
- </tr>
- <tr>
- <td colspan="2"> E-MAIL:<br />
- <input name="email" type="text" class="text" value="" size="25" /></td>
- <td></td>
- </tr>
- <tr>
- <td colspan="2" align="left">PHONE NUMBER:<br />
- <input name="phone" type="text" class="text" value="" size="3" maxlength="3" />
- <input name="phone2" type="text" class="text" value="" size="3" maxlength="3" />
- <input name="phone3" type="text" class="text" value="" size="4" maxlength="4" />
- </tr>
- <tr>
- <td colspan="2" align="left">HOW CAN WE HELP?<br />
- <textarea name="comments" cols="55" rows="5"></textarea> </tr>
- <tr>
- <td colspan="2" align="left"><input type="submit" class="custombutton" value="" name="send_email" style="background-image:url(submit.jpg); width:75px; height:31px; border:0;" /> </tr>
- </table>
- </form>