JQuery validate credit card exp date as future date?

You're not actually getting it to catch a past date. If you're passing a date like this "11/2010" to your Date.parse() it is returning NaN (or Not a Number) which is the logical equivalent to returning false.

You're not actually getting it to catch a past date. If you're passing a date like this "11/2010" to your Date.parse(), it is returning NaN (or Not a Number) which is the logical equivalent to returning false. Try doing this to see what I mean: alert( Date.

Parse('11/2010') ); If you add a day number, it should work. Something like: var startdatevalue = '11/1/2010'; Of course, this example uses a hard coded date. If the values are stored as 11/2010, you could try something like this: // Get the index of the "/" var separatorIndex = value.

IndexOf('/'); // Add "/1" before the separatorIndex so we end up with MM/1/YYYY var startDate = value. Substr( 0, separatorIndex ) + '/1' + value. Substr( separatorIndex ); // Do the same with the expiration date var expDate = $("#ExpirationDate").val(); separatorIndex = expDate.

IndexOf('/'); expDate = expDate. Substr( 0, separatorIndex ) + '/1' + expDate. Substr( separatorIndex ); // Return the comparison return Date.

Parse(startDate).

Patrick, I am testing with the above now. I'm not sure why I need to add the "/1" to the date. The date can only be entered as MM/YYYY and I just need to validate that the entered MM/YYYY is ahead of the current MM/YYYY – Dirty Bird Design Jul 12 '10 at 16:31 @Dirty - The reason is that Date.parse() does not accept the MM/YYYY format, so we're just adding in a day number to make it happy.It's just a temporary fix to make your desired format work with Date.parse().

It doesn't ultimately change the input value. – user113716 Jul 12 '10 at 16:55 @Patrick - Interesting...Assuming you entered 07/2015 as the date, (I used the above code and stuck in an alert(startDate); and an alert(expDate); )Both dates are the same, except for instance, startDate val = 7/1/2015 and expDate = 07/2015.It returns false, it doesn't appear to be comparing the current (today's) date against the exp. Date, even though return Date.parse....appears correct – Dirty Bird Design Jul 12 '10 at 17:03 @Dirty - If you're saying that you applied the fix to both dates, and it still returns false, that is because you're doing a "less than" comparison.

To make it return true when the dates are equal, you need to compare "less than or equal to", as in – user113716 Jul 12 '10 at 17:24 @Patrick - almost, but it still just compares the date you entered as exp date to itself, it's not grabbing the date from anywhere. With the below code, it returns true for any date. – Dirty Bird Design Jul 12 '10 at 18:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions