Validation on Credit Card Date

10 years ago
If a customer does not specifically select the Credit Card Expiration Date and leaves it as the default (01/Current Year), then the result on Confirmation of the order is an error saying their credit card is expired.

This may be counter-intuitive for most people as they have no clue that they neglected to change the Expiration date on the Payment info (it happens).  I got a very nasty email telling me I needed to "fix my store" and lost a $50 order.  After testing it, I discovered she left the expiration date the default.

I would suggest defaulting the Month and Year to -- / ---- and validate off that to force the user to enter a date.
10 years ago
For reference, I changed  Templates/Payment/AuthorizeNET/PaymentModule.ascx.cs

        private void BindData()
        {
            creditCardExpireYear.Items.Add(new ListItem("----", "----")); <!--Line Added-->
            for (int i = 0; i < 15; i++)
            {
                string year = Convert.ToString(DateTime.Now.Year + i);
                creditCardExpireYear.Items.Add(new ListItem(year, year));
            }

            creditCardExpireMonth.Items.Add(new ListItem("--", "--")); <!--Line Added-->

            for (int i = 1; i <= 12; i++)
            {
                string text = (i < 10) ? "0" + i.ToString() : i.ToString();
                creditCardExpireMonth.Items.Add(new ListItem(text, i.ToString()));
            }
        }

Then I attached a CompareValidator to the Month and another to the Year textfields with Operator = "DataTypeCheck" and Type = Integer.
<asp:CompareValidator ID="ExpireMonthCompareValidator" runat="server"
                ErrorMessage="Invalid Expiration Month"
                ControlToValidate="creditCardExpireMonth/Year" Display="Dynamic"
                Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>
10 years ago
This was very helpful, thanks!