Thanks to all the other SO questions regarding javascript and comparing dates, I was able to come up with something that works well for my situation. Now, I just need to clear the input field if the date entered is more than 30 days old.
function ChngStatusEffective(obj)
{
p=/(\d{1,2})\/(\d{1,2})\/(\d{1,4})/;
if (!obj.value.match(p)) return;
num=new Array();
num=obj.value.match(p);
if (num[1].length == 1) num[1]="0" + num[1];
if (num[2].length == 1) num[2]="0" + num[2];
if (num[3].length == 1) num[3]="200" + num[3];
if (num[3].length == 2) num[3]="20" + num[3];
strValue= num[1] + "/" + num[2] + "/" + num[3];
var today = new Date ();
var Date2 = new Date (strValue);
var Days = Math.floor((Date2.getTime() - today.getTime())/(1000*60*60*24));
alert('Days between two dates is: ' + Days);
if (Days >= 0)
{
alert('Future dates are not allowed ' + Days);
// document.getElementByName('statuseffective').value();
$('#stauseffective').val('');
return false;
}
else if ((Days === -1) || (Days > -31))
{
alert('Date entered looks good' + Days );
}
else
{
alert('Are you sure you entered the correct date? ' + Days);
}
validateUSDate( strValue )
}
The function is called:
<input type="text" name="statuseffective" onchange="ChngStatusEffective(this)" />
I need only this input field name, statuseffective
to be blanked. NOTE: there could be one input field or there could be 100. I only need the one input field blanked.