i\'ve a form user can enter any date , but i want to set a date range validation . for example: from 1-12-2012 to 1-1-2013 and the system can\'t accept any date from user that n
You can make a function like this:
function checkMyDateWithinRange(myDdate){
var startDate = new Date(2012, 11, 1);
var endDate = new Date(2012, 0, 1);
if (startDate < myDate && myDate < endDate) {
return true;
}
return false;
}
and test any date like calling this function:
var inputDate= document.getElementById('tbDate'),
date = new Date(inputDate.value);
if(!checkMyDateWithinRange(date)){
alert('Date is not in range!!!');
}
Here is Working Demo