Hi,
I'm working on a form that has already been created for 2004 & updating it for 2005. The previous web developer used the following code to validate the credit card expiration date form field. I'm not sure what she was doing here, or if it will still be accurate for 2005. Can anyone both explain to me what she was doing, tell me how to change it to be accurate for 2005, and possibly even offer a better way of validating the expiration date of a credit card?
This is the validation code:
<cfif Evaluate(DateCompare(Creat
eDate(Form
.cardExpYe
ar, Form.cardExpMonth, "01"), "2004-06-01") + DateCompare(CreateDate(For
m.cardExpY
ear, Form.cardExpMonth, "20"), "2015-09-01"))>
<cfset errorcount = errorcount + 1>
</cfif>
This is the form field:
<tr valign="top">
<td align="right"><B<cfif Evaluate(DateCompare(Creat
eDate(Form
.cardExpYe
ar, Form.cardExpMonth, "01"), "2005-08-01") + DateCompare(CreateDate(For
m.cardExpY
ear, Form.cardExpMonth, "20"), "2014-09-01")) and formmode NEQ "initial" and form.payment_type NEQ "Check" AND Form.check3 NEQ ""> class="error"<cfelse> style="color: #request.bgcolor#"</cfif>>
Expiration
Date</b></td>
<td><select name="cardExpMonth" class="formField">
<cfloop index="i" from="1" to="12">
<option <cfif DateFormat(CreateDate(2005
, i, 01), "mm") EQ form.cardexpmonth>selected
</cfif>value="#DateFormat(
CreateDate
(2005, i, 01), "mm")#">#DateFormat(Create
Date(2005,
i, 01), "MMMM")# (#DateFormat(CreateDate(20
05, i, 01), "mm")#)</option>
</cfloop>
</select>
<select name="cardExpYear" class="formField">
<cfloop index="i" from="05" to="14">
<option <cfif DateFormat(CreateDate(i, 01, 01), "yy") EQ form.cardexpyear>selected </cfif>value="#DateFormat(
CreateDate
(i, 01, 01), "yy")#">20#DateFormat(Crea
teDate(i, 01, 01), "yy")#</option>
</cfloop>
</select>
</td>
</tr>
Thanks,
Katrina
Start Free Trial