Thursday, August 20, 2009

Compare two dates

When working with the date of birth we need to check the date. We can check the date by writing the server side script. But when writing the server side script it takes so much time for the user which may not be usefull in some scenarios.

Below is the sample javascript method which compares the two date and proivdes the result whether the entered date is greater than the current date.

function comparedates()
{
var userdate=Date.parse("06/19/2008");

var currentdate=new Date;
if(userdate>Date.parse(currentdate))
{
alert("User Entered Date is greater then Current Date.");
}
else
{
alert("User Entered Date is less than the Current Date");
}
}

1 comment:

  1. Hi, I Saw Your Link in Bing.com I Love Your Blogs Kindly See my Link Here a New Alternative Money Making Network alternative to adbrite here

    ReplyDelete