To check that date in textbox should be less then current date.

Amatya
Posted by Amatya under JavaScript category on | Points: 40 | Views : 454
function checkDate()
{
var date1 = document.getElementById("<%=txtDOI.ClientID%>");
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
var StartDate = date1.value.split("/");
{
if (parseInt(eval(StartDate[2])) > yyyy)
{
alert("Enter Date is more then current date!");
date1.focus();
return (false);
}
else if (parseInt(eval(StartDate[2])) == yyyy)
{
if (parseInt(StartDate[1]) > mm)
{
alert("Enter Date is more then current date!");
date1.focus();
return (false);
}
else if (parseInt(eval(StartDate[1])) == mm)
{
if (parseInt(StartDate[0]) > dd)
{
alert("Enter Date is more then current date!");
date1.focus();
return (false);
}
else if (parseInt(eval(StartDate[0])) > dd)
{
alert("Enter Date is more then current date!");
date1.focus();
return (false);
}
}
}
}
}


hope it helps you all.
Thanks
Amatya

Comments or Responses

Login to post response