Well, you need both month and year. Month and Year are obviously numeric,
so you can probably create a more intuitive logic like:
<cfif not IsNumeric(form.cardExpMonth) or not IsNumeric(form.cardExpYear)>
I would just prevent the drop down select lists not to have 0 as an option.
The months are 1-12 and you should default it to 1. The year will be always
defaulted to this year as you don't accept cards from last year.
If you are afraid of someone tampering with the data in between
transmissions, I would add an extra validation:
<cfif not IsNumeric(form.cardExpMonth) or not IsNumeric(form.cardExpYear)>
<cfif form.cardExpMonth lte 0 or form.cardExpYear lte 0>
This accounts from 0 and negative number tampering.
Teddy
On 11/6/06, Will Tomlinson <[EMAIL PROTECTED]> wrote:
>
> Hey, I sometimes use this bit of code to handle validation.
>
> <cfif Len(FORM.cardexpmonth) EQ 0 OR Len(FORM.cardexpyear) EQ 0>
> <script>
> alert ("Please select a credit card expiration month/year");
> history.back();
> </script>
> <p>You must select a valid expiration date before submitting form</p>
> <p><cfoutput><a href="#CGI.http_referer#"><Go back</a></cfoutput></p>
> <cfabort>
> </cfif>
>
> FORM.cardexpmonth and year are dropdown menus. If they didnt make a
> selection, this script kicks in. If JS is turned off, the Text with link
> kicks in.
>
> ANybody got a better way to handle this? OR is this good enough. Or is
> this way incredibly tacky?
>
> Will
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259284
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4