ugly
11-10-2004, 06:14 PM
hi
i want to validate a date in the format mm/dd/yyyy.i want users to enter 2 digit month and 2 digit date and 4 digit year.
i am doing some validation the date should be 1st or 15 th of month it's working fine.i want to alert if they don't enter in this format mm/dd/yyyy.i want to alert a separate message box if date pattern not matches.
my code is
var xVal=window.document.frmNew.txtDate.value;
var xDate = new Date(xVal);
var today = new Date();
if (xDate > today && (xDate.getDate()==15 || xDate.getDate()==01))
{
return true;
}
alert("The effective date should be the 1st or 15th of the month and be greater than current date.");
window.document.frmNew.txtDate.focus();
return false;
}
i want to validate a date in the format mm/dd/yyyy.i want users to enter 2 digit month and 2 digit date and 4 digit year.
i am doing some validation the date should be 1st or 15 th of month it's working fine.i want to alert if they don't enter in this format mm/dd/yyyy.i want to alert a separate message box if date pattern not matches.
my code is
var xVal=window.document.frmNew.txtDate.value;
var xDate = new Date(xVal);
var today = new Date();
if (xDate > today && (xDate.getDate()==15 || xDate.getDate()==01))
{
return true;
}
alert("The effective date should be the 1st or 15th of the month and be greater than current date.");
window.document.frmNew.txtDate.focus();
return false;
}