<cfif isdefined("form.firstname")>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<tr>
<td>*First Name:</td>
<td><cfinput type="text" name="firstname" required="yes" id="firstname" tabindex="1" maxlength="20"></td>
</tr>
<tr>
<td>*Last Name:</td>
<td ><cfinput type="text" name="lastname" required="yes" id="lastname" tabindex="2" maxlength="20"></td>
</tr>
<tr>
<td>*Email:</td>
<td ><cfinput type="text" name="email" validateat="onsubmit" validate="email" required="yes" id="email" tabindex="3" maxlength="50"></td>
</tr>
<tr>
<td>*Verify Email:</td>
<td ><cfinput type="text" name="emailverify" required="yes" id="emailverify" tabindex="4" maxlength="50"></td>
</tr>
<tr>
<td>*Primary Phone:</td>
<td ><cfinput type="text" name="primaryphone" validateat="onsubmit" validate="telephone" required="yes" id="primaryphone" tabindex="4" maxlength="12" typeahead="no" showautosuggestloadingicon="true"></td>
</tr>
<tr>
<td>Secondary Phone:</td>
<td><cfinput type="text" name="secondaryphone" id="secondaryphone" tabindex="5" maxlength="12"></td>
</tr>
<tr>
<td>Street:</td>
<td ><cfinput type="text" name="address" id="address" tabindex="6" maxlength="50"></td>
</tr>
<tr>
<td>City:</td>
<td ><cfinput type="text" name="city" id="city" tabindex="7" maxlength="20"></td>
</tr>
<tr>
<td>State:</td>
<td ><cfselect name="State" id="State" tabindex="8">
<option value=" " selected="selected"> </option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SC</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</cfselect></td>
</tr>
<tr>
<td>Zip:</td>
<td ><cfinput type="text" name="postalcode" validateat="onsubmit" validate="zipcode" id="postalcode" tabindex="9" maxlength="5"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><cfinput type="submit" name="Submit" value="Submit" id="Submit" tabindex="10"></div></td>
<td ><cfinput type="button" name="cancel" id="Reset" value="Cancel" onclick="history.back()" tabindex="11"></td>
</tr>
</cfform>
</table>
</div>
How do I make sure to form fields match
Page 1 of 111 Replies - 3242 Views - Last Post: 19 March 2009 - 01:56 PM
#1
How do I make sure to form fields match
Posted 18 March 2009 - 02:46 PM
Replies To: How do I make sure to form fields match
#2
Re: How do I make sure to form fields match
Posted 18 March 2009 - 04:47 PM
cumupkid, on 18 Mar, 2009 - 01:46 PM, said:
<cfif isdefined("form.firstname")>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<tr>
<td>*First Name:</td>
<td><cfinput type="text" name="firstname" required="yes" id="firstname" tabindex="1" maxlength="20"></td>
</tr>
<tr>
<td>*Last Name:</td>
<td ><cfinput type="text" name="lastname" required="yes" id="lastname" tabindex="2" maxlength="20"></td>
</tr>
<tr>
<td>*Email:</td>
<td ><cfinput type="text" name="email" validateat="onsubmit" validate="email" required="yes" id="email" tabindex="3" maxlength="50"></td>
</tr>
<tr>
<td>*Verify Email:</td>
<td ><cfinput type="text" name="emailverify" required="yes" id="emailverify" tabindex="4" maxlength="50"></td>
</tr>
<tr>
<td>*Primary Phone:</td>
<td ><cfinput type="text" name="primaryphone" validateat="onsubmit" validate="telephone" required="yes" id="primaryphone" tabindex="4" maxlength="12" typeahead="no" showautosuggestloadingicon="true"></td>
</tr>
<tr>
<td>Secondary Phone:</td>
<td><cfinput type="text" name="secondaryphone" id="secondaryphone" tabindex="5" maxlength="12"></td>
</tr>
<tr>
<td>Street:</td>
<td ><cfinput type="text" name="address" id="address" tabindex="6" maxlength="50"></td>
</tr>
<tr>
<td>City:</td>
<td ><cfinput type="text" name="city" id="city" tabindex="7" maxlength="20"></td>
</tr>
<tr>
<td>State:</td>
<td ><cfselect name="State" id="State" tabindex="8">
<option value=" " selected="selected"> </option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SC</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</cfselect></td>
</tr>
<tr>
<td>Zip:</td>
<td ><cfinput type="text" name="postalcode" validateat="onsubmit" validate="zipcode" id="postalcode" tabindex="9" maxlength="5"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><cfinput type="submit" name="Submit" value="Submit" id="Submit" tabindex="10"></div></td>
<td ><cfinput type="button" name="cancel" id="Reset" value="Cancel" onclick="history.back()" tabindex="11"></td>
</tr>
</cfform>
</table>
</div>
All you have to do is a simple <cfif> statement.
<cfif form.email eq form.verifyemail> ...do the query... </cfelse> <cfset session.errormessage = "Email's Do Not Match"> Send them back to the form. At the top of the form do </cfif> On The form: <cfoutput>#session.errormessage#</cfoutput> <cfscript> structdelete(session,"errormessage") </cfscript>
That way people will know why it didn't work.
#3
Re: How do I make sure to form fields match
Posted 19 March 2009 - 04:39 AM
<cfform> <cfoutput>#session.errormessage#</cfoutput> <cfscript> structdelete(session,"errormessage") </cfscript>
I get error message
The start tag must have a matching end tag. An explicit end tag can be provided by adding </cfscript>. If the body of the tag is empty, you can use the shortcut <cfscript .../>.
The CFML compiler was processing:
A cfscript tag beginning on line 23, column 2.
Here is the code up to that point...
<cfif isdefined("form.firstname")>
<cfif form.email eq form.verifyemail>
...do the query...
<cfelse>
<cfset session.errormessage = "Email's Do Not Match">
Send them back to the form. At the top of the form do
</cfif>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<cfoutput>#session.errormessage#</cfoutput>
<cfscript>
structdelete(session,"errormessage")
</cfscript>
This post has been edited by cumupkid: 19 March 2009 - 04:59 AM
#4
Re: How do I make sure to form fields match
Posted 19 March 2009 - 06:48 AM
cumupkid, on 19 Mar, 2009 - 03:39 AM, said:
<cfform> <cfoutput>#session.errormessage#</cfoutput> <cfscript> structdelete(session,"errormessage") </cfscript>
I get error message
The start tag must have a matching end tag. An explicit end tag can be provided by adding </cfscript>. If the body of the tag is empty, you can use the shortcut <cfscript .../>.
The CFML compiler was processing:
A cfscript tag beginning on line 23, column 2.
Here is the code up to that point...
<cfif isdefined("form.firstname")>
<cfif form.email eq form.verifyemail>
...do the query...
<cfelse>
<cfset session.errormessage = "Email's Do Not Match">
Send them back to the form. At the top of the form do
</cfif>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<cfoutput>#session.errormessage#</cfoutput>
<cfscript>
structdelete(session,"errormessage")
</cfscript>
My bad the structdelete(session,"errormessage") needs a semicolon after it.
[code]
<cfscript>
structdelete(session,"errormessage");
</cfscript>
#5
Re: How do I make sure to form fields match
Posted 19 March 2009 - 07:08 AM
The requested scope session has not been enabled.
Before session variables can be used, the session state management system must be enabled using the cfapplication tag.
Thanks again.
#6
Re: How do I make sure to form fields match
Posted 19 March 2009 - 07:19 AM
cumupkid, on 19 Mar, 2009 - 06:08 AM, said:
The requested scope session has not been enabled.
Before session variables can be used, the session state management system must be enabled using the cfapplication tag.
Thanks again.
Oh in your apllication.cfm/.cfc page you need to enable session management. If you don't now how the application page go to Adobe ColdFusion LiveDocs Read up on Application management there.
#7
Re: How do I make sure to form fields match
Posted 19 March 2009 - 07:28 AM
xheartonfire43x, on 19 Mar, 2009 - 06:19 AM, said:
Actually scratch that. Because everything is happening on the same page you don't need to do a session.
<cfset errormessage = "Your emails did not match">
<cfif isDefined('errormessage')>
<cfoutput>#errormessage#</cfoutput>
</cfif>
That is all you need. You should still read up about application.cfc's
This post has been edited by xheartonfire43x: 19 March 2009 - 07:29 AM
#8
Re: How do I make sure to form fields match
Posted 19 March 2009 - 08:17 AM
Tried to enable sessions, but not getting it to work.
<cfcomponent>
<cfapplication name="session.errormessage"
sessionmanagement="yes"
sessiontimeout="#CreateTimeSpan(0,0,20,0)#">
<cfset this.name="mysqlcf_pisanellos">
<cffunction name="onrequeststart" access="public" returntype="void">
<cfif NOT isdefined("application.datasource")>
<cfset application.datasource="mysqlcf_pisanellos">
</cfif>
</cffunction>
</cfcomponent>
Thanks again.
#9
Re: How do I make sure to form fields match
Posted 19 March 2009 - 08:24 AM
This is what I have.
<cfif isdefined("form.firstname")>
<cfif form.email eq form.verifyemail>
...do the query...
<cfelse>
<cfset session.errormessage = "Email's Do Not Match">
Send them back to the form. At the top of the form do
</cfif>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<cfoutput>#session.errormessage#</cfoutput>
<cfscript>
structdelete(session,"errormessage");
</cfscript>
Where does this go?
<cfset errormessage = "Your emails did not match">
<cfif isDefined('errormessage')>
<cfoutput>#errormessage#</cfoutput>
</cfif>
#10
Re: How do I make sure to form fields match
Posted 19 March 2009 - 09:55 AM
<cfif isdefined("form.firstname")>
<cfif form.email eq form.verifyemail>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
<cfelse>
<cfset errormessage = "Your emails did not match">
</cfif>
</cfif>
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<cfif isDefined('errormessage')>
<cfoutput>#errormessage#</cfoutput>
</cfif>
Now, how do I get it to retain all the other fields information if the emails dont match?
So people dont have to refill all the information just because the email is wrong?
#11
Re: How do I make sure to form fields match
Posted 19 March 2009 - 10:51 AM
cumupkid, on 19 Mar, 2009 - 08:55 AM, said:
So people dont have to refill all the information just because the email is wrong?
Just do another <cfif> statement in the form of <cfif isDefined('form."formfield"') for each input. or do this.
<cfif isdefined("form.firstname")>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
</cfif>
<cfparam name="form.firstname" default="">
<cfparam name="form.lastname" default="">
<cfparam name="form.email" default="">
<cfparam name="form.emailverify" default="">
<cfparam name="form.primaryphone" default="">
<cfparam name="form.secondaryphone" default="">
<cfparam name="form.address" default="">
<cfparam name="form.city" default="">
<cfparam name="form.state" default="">
<cfparam name="form.postalcode" default="">
<div id="leftHeading">Join our email list</div>
<div id="DBTable">
<table border="0" cellspacing="0" cellpadding="2" align="center">
<cfform>
<tr>
<td>*First Name:</td>
<td><cfinput type="text" name="firstname" value="#form.firstname#" required="yes" id="firstname" tabindex="1" maxlength="20"></td>
</tr>
<tr>
<td>*Last Name:</td>
<td ><cfinput type="text" name="lastname" value="#form.lastname#" required="yes" id="lastname" tabindex="2" maxlength="20"></td>
</tr>
<tr>
<td>*Email:</td>
<td ><cfinput type="text" name="email" value="#form.email#" validateat="onsubmit" validate="email" required="yes" id="email" tabindex="3" maxlength="50"></td>
</tr>
<tr>
<td>*Verify Email:</td>
<td ><cfinput type="text" name="emailverify" value="#form.emailverify#" required="yes" id="emailverify" tabindex="4" maxlength="50"></td>
</tr>
<tr>
<td>*Primary Phone:</td>
<td ><cfinput type="text" name="primaryphone" value="#form.primaryphone#" validateat="onsubmit" validate="telephone" required="yes" id="primaryphone" tabindex="4" maxlength="12" typeahead="no" showautosuggestloadingicon="true"></td>
</tr>
<tr>
<td>Secondary Phone:</td>
<td><cfinput type="text" name="secondaryphone" value="#form.secondaryphone#" id="secondaryphone" tabindex="5" maxlength="12"></td>
</tr>
<tr>
<td>Street:</td>
<td ><cfinput type="text" name="address" value="#form.address#" id="address" tabindex="6" maxlength="50"></td>
</tr>
<tr>
<td>City:</td>
<td ><cfinput type="text" name="city" value="#form.city#" id="city" tabindex="7" maxlength="20"></td>
</tr>
<tr>
<td>State:</td>
<td ><cfselect name="State" id="State" tabindex="8" selected="#form.state#">
<option value=" " selected="selected"> </option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SC</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</cfselect></td>
</tr>
<tr>
<td>Zip:</td>
<td ><cfinput type="text" name="postalcode" value="#form.postalcode#" validateat="onsubmit" validate="zipcode" id="postalcode" tabindex="9" maxlength="5"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"><cfinput type="submit" name="Submit" value="Submit" id="Submit" tabindex="10"></div></td>
<td ><cfinput type="button" name="cancel" id="Reset" value="Cancel" onclick="history.back()" tabindex="11"></td>
</tr>
</cfform>
</table>
</div>
The only one that I don't know if it will work is the state. You might either have to put all of those in a database (which isn't a bad idea) and call it into a query which you can loop through for the <cfselect> tag or do <cfif> statements around every one of them
#12
Re: How do I make sure to form fields match
Posted 19 March 2009 - 01:56 PM
Worked great. Thanks.
I think yours and mine only differ in one area.
<cfif isdefined("form.firstname")>
<cfif form.email eq form.verifyemail>
<cfinvoke
component="cfcs.customers" method="insertcustomer">
<cfinvokeargument name="formdata" value="#form#"/>
</cfinvoke>
<cflocation url="index.cfm?thankyou" addtoken="no">
<cfelse>
<cfset errormessage = "Your email address did not match">
</cfif>
</cfif>
Thanks again.
|
|

New Topic/Question
Reply




MultiQuote



|