Yesterday's date using Java Script

Hi

I want to validate whether the entered date in the textbox is lessar then todays date. How can i do this. Help Me

Thanks

[143 byte] By [Jackuline] at [2007-12-26]
# 1
Moved to the JScript forum
KenTucker at 2007-9-4 > top of Msdn Tech,.NET Development,JScript for the .NET Framework...
# 2
Below is the code snippet

function compareDates()
{
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var userDate = new Date("11/8/2006"); // Get user date in mm/dd/yyyy format
if(today.getTime() > userDate.getTime())
{
alert("User date is less than Today's");
}
else if (today.getTime() == userDate.getTime())
{
alert("Dates are equal");
}
else
{
alert("User date is greater than Today's");
}
}

If you need more on Date Objects members then please refer msdn help at http://msdn2.microsoft.com/en-us/library/cd9w2te4.aspx
RamakrishnaNeela at 2007-9-4 > top of Msdn Tech,.NET Development,JScript for the .NET Framework...

.NET Development

Site Classified