Hello ?
I am capturing a month and year from two combo boxes in a form (cardMonth and cardYear). I concatenate them to get 12/2004 for example. Then I want to compare it agains today, 4/2004. However it keeps evaluating to false. I have to convert the strings to dates.
How? Do I use some type of date format function?
In VBA there is a CDate function….is there something similar in Javascript that will convert a string to a date?
Here is my code:
function formValidate()
{
var now = new Date();
var creditExp;
var checkNow;
creditExp=document.OrderEntry.cardMonth.value + “/” + document.OrderEntry.cardYear.value;
checkNow=now.getMonth()+1 + “/” + now.getYear();
if (creditExp>=now.getDate())
{
alert(“Placed order”);
}else{
alert(“This credit card has expired.”);
}
}
Any guidance is greatly appreciated – thanks!
Heather