Solved

Credit card date validation

Posted on 2009-04-11
2
732 Views
Last Modified: 2012-05-06
Hello everyone,

I have been looking for days for a good solution to this and have had no luck.  What I want to do is simply use an ASP.net validator (probably regular expression validator) to validate a credit card expiration date in the format of (MM/YYYY) on the client side. Does anyone have any ideas of how to implement this.  If there is no way to use an ASP.net validator for this, does anyone know of a good javascript to use?  
Thanks

Jay  
0
Comment
Question by:jwoodhams
2 Comments
 
LVL 18

Accepted Solution

by:
Ajay Sharma earned 500 total points
ID: 24124722
Use Regex:

^((0[1-9])|(1[0-2]))\/(\d{4})$

The above regex code calculates only the month and year. It can not evaluate that if the date is less then today or not.

Also read http://www.codeproject.com/KB/validation/creditcardvalidator.aspx

For more complex conditions use custom validator.

Resources for custom validator:

http://asp.net-tutorials.com/validation/custom-validator/

http://www.4guysfromrolla.com/articles/073102-1.aspx

http://www.w3schools.com/ASPNET/showasp.asp?filename=demo_customvalidator

0
 
LVL 1

Author Closing Comment

by:jwoodhams
ID: 31569196
Thanks, this is actually what I started out with but, I had my syntax wrong.  Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now