Solved

Credit card date validation

Posted on 2009-04-11
2
738 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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