Problem Reagrding DateComparison
-
Hello everyone, I have a small doubt regarding DateComparsion.I have a two textboxe's and an image button.When i enter the two dates i want to check that txtstartdate should be less than txtenddate using javascript when the imagebutton is clicked,name those two textboxes id as txtstartdate and txtendate.Plz anybody help me in writing this code. ThankX in advance, Murali Murali
-
Hello everyone, I have a small doubt regarding DateComparsion.I have a two textboxe's and an image button.When i enter the two dates i want to check that txtstartdate should be less than txtenddate using javascript when the imagebutton is clicked,name those two textboxes id as txtstartdate and txtendate.Plz anybody help me in writing this code. ThankX in advance, Murali Murali
hope this will help you function DateComparison(){ var startDate; var endDate; startDate = document.formName.txtStartDate.value; endDate = document.formName.txtEndDate.value; var stYear, enYear, stMonth, enMonth, stDay, enDay; stYear = startDate.substring(6,10); enYear = endDate.substring(6,10); stMonth = startDate.substring(3,5); enMonth = endDate.substring(3,5); stDay = startDate.substring(0,2); enDay = endDate.substring(0,2); if (stYear > enYear) { return false; } else if (stYear == enYear) { if (stMonth > enMonth) { return false; } else if (stMonth == enMonth) { if (stDay > enDay) { return false; } } } return true; } Regards John