Skip to main content
Participant
September 11, 2008
Question

Coldfusion form validation: Changing the "Subject" of an email based on server date/time

  • September 11, 2008
  • 1 reply
  • 1074 views
Hi,

I've provided a basic coldfusion email template for you to edit if necessary.

In my validation I'd like to check the date / time on the server.

If the date entered into the form is within 24 hours of the server date / time then insert "Urgent" into the subject of the email.

Along with that I'd like to add a "read reciept to my email" if thats possible.

Any ideas?



<!--- Form variables here --->
<cfparam name="FORM.FirstName" default="">
<cfparam name="FORM.LastName" default="">
<cfparam name="FORM.Email" default="">
<cfparam name="FORM.Phone" default="">
<cfparam name="FORM.Comments" default="">
<cfparam name="FORM.Action" default="">
<cfparam name="URL.Msg" default="">
<cfset VARIABLES.Msg="#URL.Msg#">

<cfif VARIABLES.Msg is "" and FORM.Action is "Submit">
<!--- Validation --->
<cfif Trim(FORM.FirstName) is "">
<cfset VARIABLES.Msg=VARIABLES.Msg & "<li>You must enter your first name</li>">
</cfif>
<cfif Trim(FORM.LastName) is "">
<cfset VARIABLES.Msg=VARIABLES.Msg & "<li>You must enter your last name</li>">
</cfif>
<cfif Trim(FORM.Email) is "">
<cfset VARIABLES.Msg=VARIABLES.Msg & "<li>You must enter your Email Address</li>">
</cfif>
<cfif Trim(FORM.Phone) is "">
<cfset VARIABLES.Msg=VARIABLES.Msg & "<li>You must enter your Phone Number</li>">
</cfif>
<cfif Trim(FORM.Comments) is "">
<cfset VARIABLES.Msg=VARIABLES.Msg & "<li>You must describe your query</li>">
</cfif>
<!--- Process data mailto: --->
<cfmail to="email@email.com"
cc="#FORM.Email#"
from="SENDER"
subject="SUBJECT" type="html">
Dear #FirstName# The Following details have been processed: #Form.FirstName# #Form.LastName# #Form.Phone# #Form.Email# #Form.Comments#
</cfmail>
<cfif VARIABLES.Msg is "">
<!--- Process finished either cf location or URLmessage --->
<cflocation url="baseform.cfm?Msg=#URLEncodedFormat('Information validated & posted - Thank you!')#" addtoken="No">
</cfif>
</cfif>
<!--- ERROR MESSAGE appears here above form --->
<cfoutput>
<cfif VARIABLES.Msg is not "">
<ul>
#VARIABLES.Msg#
</ul>
</cfif>
<form action="baseform.cfm" method="POST" enctype="multipart/form-data">
<table cellspacing="2" cellpadding="2" border="0" class="form_table">
<tr>
<th>* First Name:</th>
<td><input type="text" class="inputbox" name="FirstName" message="" validateat="onServer" value="#FORM.FirstName#" size="30"></td>
</tr>
<tr>
<th>* Last Name:</th>
<td><input type="text" class="inputbox" name="LastName" message="" validateat="onServer" value="#FORM.LastName#" size="30"></td>
</tr>
<tr>
<th>* Phone:</th>
<td><input type="text" class="inputbox" name="Phone" message="" validateat="onServer" value="#FORM.Phone#" size="20"></td>
</tr>
<tr>
<th>* Email:</th>
<td><input type="text" class="inputbox" name="Email" message="" validateat="onServer" value="#FORM.Email#" size="30"></td>
</tr>
<tr>
<th>Required Date:</th>
<td><input type="text" id="SdDays" name="SdDays" value="" size="4" maxlength="2" class="inputbox">
/
<input type="text" id="SdMonths" name="SdMonths" value="" size="4" maxlength="2" class="inputbox">
/
<input type="text" id="SdYears" name="SdYears" value="" size="6" maxlength="4" class="inputbox">
</td>
</tr>
<tr>
<th>* Query:</th>
<td><textarea name="Comments" class="inputbox" cols="40" rows="6" validateat="OnServer" message="" tooltip="tooltip in here" enabled="yes" value="#FORM.Comments#"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Action" id="Submit" value="Submit">
<input type="reset" value="Reset" id="Reset">
</td>
</tr>
</table>
</form>
</cfoutput>
    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 9, 2008
    Any progress?