Custom Tag - Card Expiration Date

<!--- Credit Card Expiration.cfm custom tag --->
<!--- Make sure that user specified a name for the form field --->
<cfif NOT IsDefined("Attributes.FieldName")>
    <!--- No Name Was Specified, stop custom tag and ask that user specify field --->
    <font color="red" size="4">You did not specify a valid Expiration Month!</font>
    <cfabort>
</cfif>

<cfif NOT IsDefined("Attributes.FieldName2")>
    <!--- No Name Was Specified, stop custom tag and ask that user specify field --->
    <font color="red" size="4">You did not specify a valid Expiration Year!</font>
    <cfabort>
</cfif>

<!--- define a variable called "Attributes.DefaultCreditCardExp" to be Current Month --->
<cfif NOT IsDefined("Attributes.DefaultCreditCardExp")>
    <!--- No Default Credit Card Expiration Was Define, Set Default To Be Current Month --->
    <cfset Attributes.DefaultCreditCardExp = "01">
</cfif>

<!--- Now Create the Select Box With The Credit Card Expiration --->
<cfoutput>
    <select name="#Attributes.FieldName#">
        <cfloop from="1" to="12" index="i">
            <cfif i EQ "1" OR i EQ "2" OR i EQ "3" OR i EQ "4" OR i EQ "5" OR i EQ "6" OR i EQ "7" OR i EQ "8" OR i EQ "9">
                <option value="0#i#"<cfif Attributes.DefaultCreditCardExp eq "0#i#"> SELECTED</CFIF>>0#i#</option>
            <cfelse>
                <option value="#i#"<cfif Attributes.DefaultCreditCardExp eq "#i#"> SELECTED</CFIF>>#i#</option>
            </cfif> 
        </cfloop>
    </select>
    <select name=
"#Attributes.FieldName2#">
        <cfset this_yeardate2 = "#DateFormat(Now(),'yy')#">
        <cfset this_yeardate =
"#DateFormat(Now(),'yyyy')#">
        <option value="#this_yeardate2#"<cfif Attributes.DefaultCreditCardExp eq "#this_yeardate#"> SELECTED</CFIF>>#this_yeardate#</option>
        <cfloop from="1" to="5" index="j">
            <cfset next_year = dateAdd(
'yyyy', #j#, now())>
            <cfset next_yeardate =
"#DateFormat(next_year,'yyyy')#">
            <cfset next_yeardate2 =
"#DateFormat(next_year,'yy')#">
            <option value="#next_yeardate2#"<cfif Attributes.DefaultCreditCardExp eq "#next_yeardate2#"> SELECTED</CFIF>>#next_yeardate#</option>
        </cfloop>
    </select>
</cfoutput>

All ColdFusion Tutorials By Author: Chris
  • Customer Complaint System
    this is just a customer complaint tracking system i put together with coldfusion. i got alot of help from easycfm.com so i figured i would get back with an app. its using an access database to store usernames and passwords. did all of the login authentication code myself because my damn server behaviors were not taking. copy the dbase somewhere and use the HCCTS datasource name enjoy
    Author: chris mcintosh
    Views: 19,354
    Posted Date: Sunday, March 23, 2003
  • Creating a Chat System in ColdFusion without using a database!
    Have you ever wanted to have your own chat room? This tutorial will help you have one, but the best thing about this tutorial is that you will not need to use any type of database!
    Author: Chris A.
    Views: 32,713
    Posted Date: Saturday, May 10, 2003
  • Random Image
    Here is a random image display. You can even upload it to the server. Uses a database.
    Author: Chris
    Views: 19,720
    Posted Date: Friday, July 25, 2003
  • Custom Tag - Card Expiration Date
    This tutorial lets you save time when you need dates for credit card processing.
    Author: Chris
    Views: 9,617
    Posted Date: Wednesday, September 8, 2004
  • Random Banner
    This will show you how to create a banner rotation app. It will track the # of views and clicks. It can display flash or image files.
    Author: Chris
    Views: 13,192
    Posted Date: Friday, December 31, 2004
  • Intro to Amazon web services
    Learn the basics of building your own eCommerce site using Amazon.coms web services and Cold Fusion.
    Author: Chris Gomez
    Views: 16,220
    Posted Date: Saturday, December 3, 2005
  • Creating a User Login Area Using a CFC
    This tutorial will show you how to create a user login area using a CFC. This is just a basic idea which can easily be modified to fit your needs
    Author: Chris
    Views: 16,758
    Posted Date: Sunday, January 8, 2006
  • Quick and Dirty Contact Forms.
    This is just a simple way to dynamicly generate contact forms without the need for a database.
    Author: Chris Bunting
    Views: 14,229
    Posted Date: Saturday, April 1, 2006
  • Deleting Session When User Leaves Your Page
    This tutorial will show you how to delete sessions when a user closes the browser.
    Author: Chris
    Views: 12,104
    Posted Date: Tuesday, July 18, 2006
Download the EasyCFM.COM Browser Toolbar!