Subscribe Now!

Enter your email address:

Wednesday, January 19, 2011

Validation of Start Date and End Date using JavaScript

I was trying to validate start date and end date. If user select the end date which is less than start date then a warning message will display which tell that End date should be greater than start date

for that i have used this Code:

[code]

function ValidateDate()
{
var StartD = document.getElementById('').value; 
var EndD = document.getElementById('').value;
var endDate = new Date(EndD ); 
var startDate= new Date(StartD );
if(StartD != '' && EndD != '' && startDate > endDate )
{
 alert("Check out date should be greater than check In Date.");
 return false;
}
if(StartD == EndD )
{
alert("Check out date should be greater than check In Date.");
return false;
}
}

[/code]

and call this function onclientclick of button event.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...