Comparing 2 dates using Javascript

hi, this is the java script Function for Comparing 2 dates..


function CheckDate()
{
var dt1 = new Date();
var dt2 = new Date();
dt1 = document.getElementById('txtFromDate').value;
dt2 = document.getElementById('txtTodate').value;

if(dt1 <= dt2)
{
return true;
}
else
{
alert('Start date must be smaller than End date.');
document.getElementById('txtTodate').value='';
document.getElementById('txtTodate').focus();
return false;
}
}

Regards
Anil Pandey


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: