Javascript Date Range Validation
Posted
on DotNetBlocks
See other posts from DotNetBlocks
Published on Fri, 06 May 2011 00:44:00 -0400
Indexed on
2011/06/20
16:37 UTC
Read the original article
Hit count: 302
JavaScript
|Tips
Here is a Javascript function that will tell you if 2 dates make a valid date range.
function isValidDateRange( objstartMonth,objstartDay, objstartYear, objendMonth,objendDay, objendYear) { var startDate = new Date(objstartYear.options[objstartYear.selectedIndex].value, objstartMonth.options[objstartMonth.selectedIndex].value, objstartDay.options[objstartDay.selectedIndex].value); var endDate = new Date(objendYear.options[objendYear.selectedIndex].value, objendMonth.options[objendMonth.selectedIndex].value, objendDay.options[objendDay.selectedIndex].value); if (startDate >= endDate){ alert("Invaild Date Range"); return false; } else{ return true; } }
© DotNetBlocks or respective owner