Click here to Skip to main content
16,019,349 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How i disable future dates using java script....have googled but no luck....thanks inadvance.
Posted
Comments
[no name] 6-May-15 6:24am    
Future Dates ?
sxaxah 6-May-15 7:00am    
yes Rajeesh future dates
[no name] 6-May-15 7:15am    
I can't get you,what's mean future dates?
sxaxah 6-May-15 7:19am    
dates that prior to current dates(upcoming dates)
[no name] 6-May-15 7:59am    
check my solution..

function CheckEnteredDate(passed) {
var arrShortMonths = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
//split the input date
var date1 = passed.value.split("-");
//replace Date1[1] month value Ex: 'Dec' with 11 i.e. 1 less than 12 and set the selDate with user input date
//date1[1] = arrShortMonths.indexOf(date1[1]);
if (date1 != '') {
date1[1] = getMonthval(date1[1]);
var selDate = new Date(date1[2], date1[1], date1[0]);
if (selDate != '' && selDate > new Date()) {
alert('Date greater than Todays Date');
}
}
}
 
Share this answer
 
Hi,

Ref:
HTML
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>

Javascript:
JavaScript
<script type="text/javascript">
$(function() {
var date = new Date();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
$('#datepicker').datepicker({
maxDate: new Date(currentYear, currentMonth, currentDate)
});
});
</script>


Html :

HTML
<p>Date: <input type="text" id="datepicker" /></p>


Ref Link : jQuery Datepicker- Disable Future Dates in Calendar
 
Share this answer
 
Comments
sxaxah 6-May-15 8:07am    
Thanks very much it works perfect :-)
[no name] 6-May-15 8:54am    
Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900