Solved

Credit card date validation

Posted on 2009-04-11
2
735 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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