Simple Credit Card Validation Help Needed!

Hi,

I need some help on my J2ME program to check if a credit card number has the right format or not. This does not have to be to any legal industry standard or anything, just a code snippet would do.

Also I have an expiry date field in my program in the format of the month followed by the year i.e. January 2008. How can I do a check to see that this expiry date that the user can choose is a date which is greater or equal to today抯 date? Then to give an error message if the month and year is less than the current month and year?

Thanks in advance,

Harry

[590 byte] By [Harry_Novicea] at [2007-10-2 11:25:37]
# 1
Hi,I really need help on this for my project. Any guidance or places to look for information would be appreciated greatly. Any advice is good advice!!Thanks in advance,Harry
Harry_Novicea at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
There must be someone out there who could help!? I have found credit card number validation, but its not compliant with J2ME ...Thanks in advance,Harry
Harry_Novicea at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
> There must be someone out there who could help!? I> have found credit card number validation, but its not> compliant with J2ME ...I'll post a code example if you answer this: what is considered to be a valid credit card number?
prometheuzza at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
I don't mean to spoil your fun, but [url= http://forum.java.sun.com/thread.jspa?threadID=451404]pkwooster posted it here[/url] a while back.
tschodta at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
If you could post some code for my expiry date problem, that would help me soooo much!
Harry_Novicea at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
http://www.darkcanyongroup.com/code/luhn_algorithm.txt
prometheuzza at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

> If you could post some code for my expiry date

> problem, that would help me soooo much!

Something like this:

private boolean isValidDate(int m, int y) {

java.util.Calendar cal = new java.util.GregorianCalendar();

int monthNow = cal.get(java.util.Calendar.MONTH)+1;

int yearNow = cal.get(java.util.Calendar.YEAR);

if(yearNow > y)

return false;

else if(yearNow < y)

return true;

else

return (monthNow <= m);

}

?

prometheuzza at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8
Thats absolute ace, just had to change the code a bit to make it J2ME compliant but once again thanks for the help.
Harry_Novicea at 2007-7-13 4:37:47 > top of Java-index,Java Mobility Forums,Java ME Technologies...