hi,
I am using the following javascript code to compare 2 dates, one of which is sysdate and the other is the date from my text field in my jsp.
function rbvalidation(ct l)
{
var cal = new Array();
cal.JAN = "January";
cal.FEB = "February";
cal.MAR = "March";
cal.APR = "April";
cal.MAY = "May";
cal.JUN = "June";
cal.JUL = "July";
cal.AUG = "August";
cal.SEP = "September" ;
cal.OCT = "October";
cal.NOV = "November";
cal.DEC = "December";
var sysDate = new Date();
var effDateChar = ctl.value; // P_EFFECTIVE_DAT E
// translate date entered by user into JS format
var bufArray = effDateChar.spl it("-");
var effDateMonth = cal[bufArray[1].toUpperCase()];
var effDateDay = bufArray[0];
var effDateYear = bufArray[2];
var effDateDate = new Date(effDateMon th+" "+ effDateDay +
", "+effDateYe ar+" 23:59:59");
// compare the 2 dates
if (effDateDate < sysDate)
{
alert("The effective date must be today's date or a later date.");
ctl.focus();
return false;
}
return true;
}
</script>
Im calling this as onChange=rbvali dation(this.val ue) in my text field....
But, it is not working.Is something wrong with the code?
I am using the following javascript code to compare 2 dates, one of which is sysdate and the other is the date from my text field in my jsp.
function rbvalidation(ct l)
{
var cal = new Array();
cal.JAN = "January";
cal.FEB = "February";
cal.MAR = "March";
cal.APR = "April";
cal.MAY = "May";
cal.JUN = "June";
cal.JUL = "July";
cal.AUG = "August";
cal.SEP = "September" ;
cal.OCT = "October";
cal.NOV = "November";
cal.DEC = "December";
var sysDate = new Date();
var effDateChar = ctl.value; // P_EFFECTIVE_DAT E
// translate date entered by user into JS format
var bufArray = effDateChar.spl it("-");
var effDateMonth = cal[bufArray[1].toUpperCase()];
var effDateDay = bufArray[0];
var effDateYear = bufArray[2];
var effDateDate = new Date(effDateMon th+" "+ effDateDay +
", "+effDateYe ar+" 23:59:59");
// compare the 2 dates
if (effDateDate < sysDate)
{
alert("The effective date must be today's date or a later date.");
ctl.focus();
return false;
}
return true;
}
</script>
Im calling this as onChange=rbvali dation(this.val ue) in my text field....
But, it is not working.Is something wrong with the code?
Comment