Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Form validation not working using Javascript and Coldfusion 3

Status
Not open for further replies.

radiance

Programmer
Jan 4, 2003
164
US
I am adding form validation to code programmed by someone else. The pages are eventually going to Paypal and use the ipn. The pages are Coldfusion, but for some reason, when I added the <cfform> to the pages, and tried to do the validation through coldfusion, I received nothing but errors. So, I tried javascript, and the form is still not returning errors when I enter invalid information or no information. Can someone tell me what I am doing wrong? Should I be changing something on the confirm page?

This is the URL:

Here is the main page for the form and it is passed to a confirm page in which all of the session variables are captured:
__________________________________________________

<cfif IsDefined(&quot;SESSION.Auth.IsLoggedIn&quot;) is &quot;true&quot;>
<cfset #loggedIn# = &quot;yes&quot;>
<cfelse>
<cfset #loggedIn# = &quot;no&quot;>
</cfif>

<cfif IsDefined(&quot;FORM.mode&quot;) is &quot;true&quot;>
<cfset #mode# = &quot;edit&quot;>
<cfelse>
<cfset #mode# = &quot;&quot;>
</cfif>

<cfset bnaibrith=&quot;Donate!&quot;>
<cfset chhead =3>
<cfset tier =4>
<cfset tierb =4>
<cfset side =5.2>
<cfset keywordspage=&quot;israel, world jewry&quot;>
<cfoutput><cfinclude template=&quot;#request.header#&quot;></cfoutput>

<script language=&quot;JavaScript&quot;>
/// Check for valid email address: look for @ and .
function isEmail(elm) {
if (elm.value.indexOf(&quot;@&quot;) != &quot;-1&quot; &&
elm.value.indexOf(&quot;.&quot;) != &quot;-1&quot;) {
return true;
}
else {
return false;
}
}

// Check for blank fields
function isFilled(elm) {
if (elm.value == &quot;&quot; || elm.value == null) {
return false;
}
else {
return true;
}
}
// Check entire form
function isReady(form) {
if (isEmail(form.email) == false) { // A real email address?
alert(&quot;Please enter a valid email address.&quot;);
form.email.focus();
return false;
}

if (isFilled(form.fullname) == false) { // first name
alert(&quot;Please enter your first name.&quot;);
form.fname.focus();
return false;
}

if (isFilled(form.fullname) == false) { // last name
alert(&quot;Please enter your last name.&quot;);
form.lname.focus();
return false;
}

if (isFilled(form.city) == false) { // city?
alert(&quot;Please enter your city.&quot;);
form.city.focus();
return false;
}

if (isFilled(form.state) == false) { // state
alert(&quot;Please select your state.&quot;);
form.state.focus();
return false;
}

if (isFilled(form.hphone) == false) { // home phone
alert(&quot;Please eneter your home phone.&quot;);
form.hphone.focus();
return false;
}

if (isFilled(form.wphone) == false) { // work phone
alert(&quot;Please select your work phone.&quot;);
form.wphone.focus();
return false;
}
return true;
}
</script>



<table border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;2&quot;>
<tr>
<td colspan=&quot;3&quot;>
<table cellpadding=&quot;2&quot; cellspacing=&quot;2&quot; border=&quot;0&quot;><tr><td><cfoutput><img src=&quot;#request.picture#sm_klutznick_jewishlife.jpg&quot; border=&quot;1&quot; bordercolor=&quot;BLACK&quot;></cfoutput></td><td class=&quot;heading4&quot;>Donate Now!</td>
</tr></table>
<br><br>

</td>
</tr>
</table>
<cfoutput>
<cfif #mode# is &quot;edit&quot;>
<p>Please make any changes in the form below. Thank you!</p>
<table border=&quot;0&quot; bgcolor=&quot;f5f5f5&quot; cellpadding=&quot;2&quot; cellspacing=&quot;2&quot;>
<form action=&quot;confirm.cfm&quot; method=&quot;post&quot; onSubmit = &quot;return isReady(this);&quot;>
<tr>
<td class=&quot;boldtext&quot;>Member Id:<br/>(if known)</td>
<td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtMemberId&quot; size = &quot;10&quot; value=&quot;#SESSION.MemberId#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>First Name:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtFName&quot; value=&quot;#SESSION.fname#&quot;></td>

<td class=&quot;boldtext&quot;>Last Name:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtLName&quot; value=&quot;#SESSION.lname#&quot; onBlur=&quot;doesExist(this.value, 'last name')&quot;></td>
<td class=&quot;text&quot;>MI:</td><td><input type=&quot;text&quot; name=&quot;txtMI&quot; size=&quot;2&quot; value=&quot;#SESSION.mi#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>Address:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtAdd1&quot; value=&quot;#SESSION.stno#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>Address 2:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtAdd2&quot; value=&quot;#SESSION.stno2#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>City:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtCity&quot; value=&quot;#SESSION.city#&quot;></td>

<td class=&quot;boldtext&quot;>State:</td>
<td class=&quot;text&quot;><select name=&quot;txtState&quot;>
<option value=&quot;&quot;>--Please select state--
<option value=&quot;AL&quot;>Alabama
<option value=&quot;AK&quot;>Alaska
<option value=&quot;AZ&quot;>Arizona
<option value=&quot;AR&quot;>Arkansas
<option value=&quot;CA&quot;>California
<option value=&quot;CO&quot;>Colorado
<option value=&quot;CT&quot;>Connecticut
<option value=&quot;DE&quot;>Delaware
<option value=&quot;FL&quot;>Florida
<option value=&quot;GA&quot;>Georgia
<option value=&quot;HI&quot;>Hawaii
<option value=&quot;ID&quot;>Idaho
<option value=&quot;IL&quot;>Illinois
<option value=&quot;IN&quot;>Indiana
<option value=&quot;IA&quot;>Iowa
<option value=&quot;KS&quot;>Kansas
<option value=&quot;KY&quot;>Kentucky
<option value=&quot;LA&quot;>Louisiana
<option value=&quot;ME&quot;>Maine
<option value=&quot;MD&quot;>Maryland
<option value=&quot;MA&quot;>Massachusetts
<option value=&quot;MI&quot;>Michigan
<option value=&quot;MN&quot;>Minnesota
<option value=&quot;MS&quot;>Mississippi
<option value=&quot;MO&quot;>Missouri
<option value=&quot;MT&quot;>Montana
<option value=&quot;NE&quot;>Nebraska
<option value=&quot;NV&quot;>Nevada
<option value=&quot;NH&quot;>New Hampshire
<option value=&quot;NJ&quot;>New Jersey
<option value=&quot;NM&quot;>New Mexico
<option value=&quot;NY&quot;>New York
<option value=&quot;NC&quot;>North Carolina
<option value=&quot;ND&quot;>North Dakota
<option value=&quot;OH&quot;>Ohio
<option value=&quot;OK&quot;>Oklahoma
<option value=&quot;OR&quot;>Oregon
<option value=&quot;PA&quot;>Pennsylvania
<option value=&quot;RI&quot;>Rhode Island
<option value=&quot;SC&quot;>South Carolina
<option value=&quot;SD&quot;>South Dakota
<option value=&quot;TN&quot;>Tennessee
<option value=&quot;TX&quot;>Texas
<option value=&quot;UT&quot;>Utah
<option value=&quot;VT&quot;>Vermont
<option value=&quot;VA&quot;>Virginia
<option value=&quot;WA&quot;>Washington
<option value=&quot;DC&quot;>Washington DC
<option value=&quot;WV&quot;>West Virginia
<option value=&quot;WI&quot;>Wisconsin
<option value=&quot;WY&quot;>Wyoming
</select></td>
<td class=&quot;boldtext&quot;>Zip:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtZip&quot; size=&quot;5&quot; value=&quot;#SESSION.zip#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>Home Phone:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtHPhone&quot; value=&quot;#SESSION.hphone#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>Work Phone:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtWPhone&quot; value=&quot;#SESSION.wphone#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>E-Mail:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtEmail&quot; value=&quot;#SESSION.email#&quot; size=&quot;30&quot;></td>
</tr>
<tr><td colspan=&quot;6&quot; align=&quot;middle&quot;><input type=&quot;SUBMIT&quot; value=&quot;Save Changes&quot;></td></tr>
</form>

</table></cfif>
</cfoutput>


<cfif #loggedIn# is &quot;yes&quot;>

<cfquery name=&quot;FindMember&quot; datasource=&quot;bbitestdb&quot;>
SELECT * FROM Members
WHERE MemberId = '#SESSION.Auth.MemberId#'
AND lname = '#SESSION.Auth.LastName#'
</cfquery>

<cfoutput query=&quot;FindMember&quot;>
<table border=&quot;0&quot; bgcolor=&quot;f5f5f5&quot; cellpadding=&quot;2&quot; cellspacing=&quot;2&quot;>
<form action=&quot;confirm.cfm&quot; method=&quot;post&quot; onSubmit = &quot;return isReady(this);&quot;>
<tr>
<td class=&quot;boldtext&quot;>Member Id:</td>
<td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtMemberId&quot; size = &quot;10&quot; value=&quot;#MemberId#&quot;></td>
</tr>
<tr>
<td class=&quot;boldtext&quot;>First Name:</td><td><input type=&quot;text&quot; name=&quot;txtFName&quot; value=&quot;#fname#&quot;></td><td>Last Name:</td><td><input type=&quot;text&quot; name=&quot;txtLName&quot; value=&quot;#lname#&quot;></td><td>MI:</td><td><input type=&quot;text&quot; name=&quot;txtMI&quot; size=&quot;2&quot;></td>
</tr>
<tr>
<td>Address:</td><td><input type=&quot;text&quot; name=&quot;address_street&quot; value=&quot;#stno#&quot;></td>
</tr>
<tr>
<td>Address 2:</td><td><input type=&quot;text&quot; name=&quot;address_street2&quot; value=&quot;#stno2#&quot;></td>
</tr>
<tr>
<td>City:</td><td><input type=&quot;text&quot; name=&quot;address_city&quot; value=&quot;#city#&quot;></td>
<td>State:</td><td><select name=&quot;txtState&quot;><option value=&quot;&quot;>--Please select state--
<option value=&quot;AL&quot;>Alabama
<option value=&quot;AK&quot;>Alaska
<option value=&quot;AZ&quot;>Arizona
<option value=&quot;AR&quot;>Arkansas
<option value=&quot;CA&quot;>California
<option value=&quot;CO&quot;>Colorado
<option value=&quot;CT&quot;>Connecticut
<option value=&quot;DE&quot;>Delaware
<option value=&quot;FL&quot;>Florida
<option value=&quot;GA&quot;>Georgia
<option value=&quot;HI&quot;>Hawaii
<option value=&quot;ID&quot;>Idaho
<option value=&quot;IL&quot;>Illinois
<option value=&quot;IN&quot;>Indiana
<option value=&quot;IA&quot;>Iowa
<option value=&quot;KS&quot;>Kansas
<option value=&quot;KY&quot;>Kentucky
<option value=&quot;LA&quot;>Louisiana
<option value=&quot;ME&quot;>Maine
<option value=&quot;MD&quot;>Maryland
<option value=&quot;MA&quot;>Massachusetts
<option value=&quot;MI&quot;>Michigan
<option value=&quot;MN&quot;>Minnesota
<option value=&quot;MS&quot;>Mississippi
<option value=&quot;MO&quot;>Missouri
<option value=&quot;MT&quot;>Montana
<option value=&quot;NE&quot;>Nebraska
<option value=&quot;NV&quot;>Nevada
<option value=&quot;NH&quot;>New Hampshire
<option value=&quot;NJ&quot;>New Jersey
<option value=&quot;NM&quot;>New Mexico
<option value=&quot;NY&quot;>New York
<option value=&quot;NC&quot;>North Carolina
<option value=&quot;ND&quot;>North Dakota
<option value=&quot;OH&quot;>Ohio
<option value=&quot;OK&quot;>Oklahoma
<option value=&quot;OR&quot;>Oregon
<option value=&quot;PA&quot;>Pennsylvania
<option value=&quot;RI&quot;>Rhode Island
<option value=&quot;SC&quot;>South Carolina
<option value=&quot;SD&quot;>South Dakota
<option value=&quot;TN&quot;>Tennessee
<option value=&quot;TX&quot;>Texas
<option value=&quot;UT&quot;>Utah
<option value=&quot;VT&quot;>Vermont
<option value=&quot;VA&quot;>Virginia
<option value=&quot;WA&quot;>Washington
<option value=&quot;DC&quot;>Washington DC
<option value=&quot;WV&quot;>West Virginia
<option value=&quot;WI&quot;>Wisconsin
<option value=&quot;WY&quot;>Wyoming
</select></td>
<td>Zip:</td><td><input type=&quot;text&quot; name=&quot;txtZip&quot; size=&quot;5&quot; value=&quot;#zip#&quot;></td>
</tr>
<tr>
<td>Home Phone:</td><td><input type=&quot;text&quot; name=&quot;txtHPhone&quot; value=&quot;#hphone#&quot;></td>
</tr>
<tr>
<td>Work Phone:</td><td><input type=&quot;text&quot; name=&quot;txtWPhone&quot; value=&quot;#wphone#&quot;></td>
</tr>
<tr>
<td>E-Mail:</td><td><input type=&quot;text&quot; name=&quot;txtEmail&quot; value=&quot;#email#&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;middle&quot;>
<input type=&quot;reset&quot; value=&quot;Reset&quot;> <input type=&quot;submit&quot; value=&quot;Start&quot;>

</td>
</tr></cfoutput>
</form></table>

<cfelseif #mode# NEQ &quot;edit&quot;>
<table border=&quot;0&quot; bgcolor=&quot;f5f5f5&quot; cellpadding=&quot;2&quot; cellspacing=&quot;2&quot;>
<tr>
<td colspan=&quot;4&quot; class=&quot;text&quot;>
<p>Please fill out the form below. You will be sent to PayPal to make a donation after the below information is confirmed. Thank you for donating to B'nai B'rith! <br><br>
<span class=&quot;itext&quot;>* denotes a required field.</span><br><br></td>
</tr>
<form action=&quot;confirm.cfm&quot; method=&quot;post&quot; onSubmit = &quot;return isReady(this);&quot;>
<tr>
<td class=&quot;text&quot;>Member Id:<br/>(if known)</td>
<td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtMemberId&quot; size = &quot;10&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*First Name:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtFName&quot;></td><td class=&quot;text&quot;>Last Name:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtLName&quot;></td><td class=&quot;text&quot;>MI:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtMI&quot; size=&quot;2&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*Address:</td><td><input type=&quot;text&quot; name=&quot;txtAdd1&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>Address 2:</td><td><input type=&quot;text&quot; name=&quot;txtAdd2&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*City:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtCity&quot;></td>
<td class=&quot;text&quot;>*State:</td><td class=&quot;text&quot;><select name=&quot;txtState&quot;><option value=&quot;&quot;>--Please select state--
<option value=&quot;AL&quot;>Alabama
<option value=&quot;AK&quot;>Alaska
<option value=&quot;AZ&quot;>Arizona
<option value=&quot;AR&quot;>Arkansas
<option value=&quot;CA&quot;>California
<option value=&quot;CO&quot;>Colorado
<option value=&quot;CT&quot;>Connecticut
<option value=&quot;DE&quot;>Delaware
<option value=&quot;FL&quot;>Florida
<option value=&quot;GA&quot;>Georgia
<option value=&quot;HI&quot;>Hawaii
<option value=&quot;ID&quot;>Idaho
<option value=&quot;IL&quot;>Illinois
<option value=&quot;IN&quot;>Indiana
<option value=&quot;IA&quot;>Iowa
<option value=&quot;KS&quot;>Kansas
<option value=&quot;KY&quot;>Kentucky
<option value=&quot;LA&quot;>Louisiana
<option value=&quot;ME&quot;>Maine
<option value=&quot;MD&quot;>Maryland
<option value=&quot;MA&quot;>Massachusetts
<option value=&quot;MI&quot;>Michigan
<option value=&quot;MN&quot;>Minnesota
<option value=&quot;MS&quot;>Mississippi
<option value=&quot;MO&quot;>Missouri
<option value=&quot;MT&quot;>Montana
<option value=&quot;NE&quot;>Nebraska
<option value=&quot;NV&quot;>Nevada
<option value=&quot;NH&quot;>New Hampshire
<option value=&quot;NJ&quot;>New Jersey
<option value=&quot;NM&quot;>New Mexico
<option value=&quot;NY&quot;>New York
<option value=&quot;NC&quot;>North Carolina
<option value=&quot;ND&quot;>North Dakota
<option value=&quot;OH&quot;>Ohio
<option value=&quot;OK&quot;>Oklahoma
<option value=&quot;OR&quot;>Oregon
<option value=&quot;PA&quot;>Pennsylvania
<option value=&quot;RI&quot;>Rhode Island
<option value=&quot;SC&quot;>South Carolina
<option value=&quot;SD&quot;>South Dakota
<option value=&quot;TN&quot;>Tennessee
<option value=&quot;TX&quot;>Texas
<option value=&quot;UT&quot;>Utah
<option value=&quot;VT&quot;>Vermont
<option value=&quot;VA&quot;>Virginia
<option value=&quot;WA&quot;>Washington
<option value=&quot;DC&quot;>Washington DC
<option value=&quot;WV&quot;>West Virginia
<option value=&quot;WI&quot;>Wisconsin
<option value=&quot;WY&quot;>Wyoming
</select></td>
<td class=&quot;text&quot;>*Zip:</td><td><input type=&quot;text&quot; name=&quot;txtZip&quot; size=&quot;5&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*Home Phone:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtHPhone&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*Work Phone:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtWPhone&quot;></td>
</tr>
<tr>
<td class=&quot;text&quot;>*E-Mail:</td><td class=&quot;text&quot;><input type=&quot;text&quot; name=&quot;txtEmail&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;middle&quot;>
<input type=&quot;reset&quot; value=&quot;Reset&quot;> <input type=&quot;submit&quot; value=&quot;Start&quot;></td><!--- </cfoutput> ---></cfif></tr></form></table>

_____________________________________________

Confirm.cfm page:

<cfset bnaibrith=&quot;Donate!&quot;>
<cfset chhead =3>
<!--- <cfset home = 1> --->
<cfset tier =4>
<cfset tierb =4>
<cfset side =5.2>
<cfset keywordspage=&quot;israel, world jewry&quot;>
<cfoutput><cfinclude template=&quot;#request.header#&quot;></cfoutput>


<!----------GET ALL FORM VARIABLES------------->
<cfif IsDefined(&quot;FORM.txtMemberId&quot;) is &quot;true&quot;>
<cfset #SESSION.MemberId# = FORM.txtMemberId>
<cfelse>
<cfset #SESSION.MemberId# = &quot;none&quot;>
</cfif>


<cfset #SESSION.fname# = FORM.txtFName>
<cfset #SESSION.lname# = FORM.txtLName>
<cfset #SESSION.mi# = FORM.txtMI>
<cfset #SESSION.stno# = FORM.txtAdd1>
<cfif IsDefined(&quot;FORM.txtAdd2&quot;) is &quot;true&quot;>
<cfset #SESSION.stno2# = FORM.txtAdd2>
<cfelse>
<cfset #SESSION.stno2# = &quot;&quot;>
</cfif>

<cfset #SESSION.city# = FORM.txtcity>
<cfset #SESSION.state# = FORM.txtstate>
<cfset #SESSION.zip# = FORM.txtzip>
<cfset #SESSION.hphone# = FORM.txthphone>
<cfset #SESSION.wphone# = FORM.txtwphone>
<cfset #SESSION.email# = FORM.txtemail>

<table cellpadding=&quot;2&quot; cellspacing=&quot;2&quot; border=&quot;0&quot;><tr><td class=&quot;text&quot;>
<span class=&quot;boldtext&quot;>Please check the information below and confirm. You will then be taken to <b>PayPal</b> to make a donation.</span>

<p><b>Donor Information:</b></p>
</td></tr>
<td>
<cfoutput>
<table>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>Member Id:</td><td class=&quot;text&quot;>#SESSION.MemberId#</td></tr>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>Name:</td><td valign=&quot;top&quot; class=&quot;text&quot;>#SESSION.fname#&nbsp;#SESSION.mi#&nbsp;#SESSION.lname#</td></tr>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>Address:</td><td valign=&quot;top&quot; class=&quot;text&quot;>#SESSION.stno#<br/>#SESSION.stno2#<br/>
#SESSION.city#, #SESSION.state#&nbsp;&nbsp;#SESSION.zip#</td></tr>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>Home Phone:</td><td valign=&quot;top&quot; class=&quot;text&quot;>#SESSION.hphone#</td></tr>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>Work Phone:</td><td valign=&quot;top&quot; class=&quot;text&quot;>#SESSION.wphone#</td></tr>
<tr><td valign=&quot;top&quot; class=&quot;boldtext&quot;>E-Mail:</td><td valign=&quot;top&quot; class=&quot;text&quot;>#SESSION.email#</td></tr>
</table>
</td></tr></table>

<form action=&quot;zdonate.cfm&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;mode&quot; value=&quot;edit&quot;>
<input type=&quot;submit&quot; value=&quot;Go Back & Edit&quot;>
</form>

<form action=&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;item_name&quot; value=&quot;General Donation&quot;>
<input type=&quot;hidden&quot; name=&quot;cmd&quot; value=&quot;_ext-enter&quot;>
<input type=&quot;hidden&quot; name=&quot;redirect_cmd&quot; value=&quot;_xclick&quot;>
<input type=&quot;hidden&quot; name=&quot;business&quot; value=&quot;website@bnaibrith.org&quot;>
<input type=&quot;hidden&quot; name=&quot;item_number&quot; value=&quot;2&quot;>
<input type=&quot;hidden&quot; name=&quot;first_name&quot; value=&quot;#SESSION.fname#&quot;>
<input type=&quot;hidden&quot; name=&quot;last_name&quot; value=&quot;#SESSION.lname#&quot;>
<input type=&quot;hidden&quot; name=&quot;address1&quot; value=&quot;#SESSION.stno#&quot;>
<input type=&quot;hidden&quot; name=&quot;address2&quot; value=&quot;#SESSION.stno2#&quot;>
<input type=&quot;hidden&quot; name=&quot;city&quot; value=&quot;#SESSION.city#&quot;>
<input type=&quot;hidden&quot; name=&quot;state&quot; value=&quot;#SESSION.state#&quot;>
<input type=&quot;hidden&quot; name=&quot;zip&quot; value=&quot;#SESSION.zip#&quot;>
<input type=&quot;hidden&quot; name=&quot;no_note&quot; value=&quot;1&quot;>
<input type=&quot;hidden&quot; name=&quot;no_shipping&quot; value=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;currency_code&quot; value=&quot;USD&quot;>
<input type=&quot;hidden&quot; name=&quot;tax&quot; value=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;return&quot; value=&quot; <input type=&quot;hidden&quot; name=&quot;notify_url&quot; value=&quot; <input type=&quot;submit&quot; value=&quot;Confirm&quot;>
</form>
</cfoutput>

<cfset chfoot =2>
<cfoutput><cfinclude template=&quot;#request.footer#&quot;></cfoutput>




<cfset chfoot =2>
<cfoutput><cfinclude template=&quot;#request.footer#&quot;></cfoutput>
 
I can't help with the cold fusion question, but I see your Javascript problem. You're referring to the wrong names in your checks. For example you refer to &quot;form.fullname&quot;. But form.fullname doesn't exist. You're confusing the cfm field names with the form names. In this case you must use &quot;first_name&quot; and &quot;last_name&quot;.

-- taf
 
I hope that this isn't your only validation. You should never trust client-side data implicitely, even if validated with JavaScript, since it is trivial for someone with malicious intent to bypass your JavaScript and enter nasty stuff to your server. JavaScript is useful for alerting users to invalid data without hitting the server, but not at all useful for sanitizing the data before being used server-side, particularly when submitting to a payment processor. Just FYI in case you weren't aware.

Sincerely,

Tom Anderson
Order amid Chaos, Inc.
 
Hello.

Thank you for your suggestions. The last email from Tom referred to additional validation for the form.

<< You should never trust client-side data implicitely, even if validated with JavaScript, since it is trivial for someone with malicious intent to bypass your JavaScript and enter nasty stuff to your server. >>

I am not validating credit card info, but I am interested in suggestions for additional validation.

Thank you so much!!
 
The best method is to build the javascript edits and then back them up with cfml edits matching as closely as you can. You don't want to be hitting the server with known bad data, yet you want to cover yourself for the few that do not have javascript turned on. You mentioned you were using cfform tags. It is not recommended to use them as they are not as robust as javascript which is backed up with regular cfml edits. Regardless of the data you want to cleanse the data as much as you can with javascript and have the coldfusion as a backup to it.

It can take some time to build both js and cfml edits, but maintaining a library can help. You can cut and paste either as needed and once you build something close to what you need it can be modified with minimal changes.

Hope this helps.
 
Re: validation

While JavaScript can alert users to invalid data before submitting, once it is submitted, you can't just assume that the data is good. I could very easily view your source code and construct my own input completely bypassing your scripts. Therefore, you must validate all info server-side as well.

For example, if you require a non-empty and unique email address, then you should use ColdFusion or other language of choice to make sure it exists, looks like an email address, and does not already exist in your database after you've accepted input from your client code. This is especially true if you use user input to modify the filesystem in any way, such as saving a file named after the person's name, etc.

I understand after reviewing your code further that in this case, you're just submitting directly to PayPal, so they will be taking care of server-side validation. If something is wrong with the data, they'll return an error. But if you ever do anything else with user data besides sending it off to someone else, server-side validation is something to keep in mind.

Sincerely,

Tom Anderson
Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top