Skip to content
Loading
Restrict future date in Calendar
  • Mangesh G
    Share Complete ASPX Page if Possible Dinesh 
  • No errors were Populated.Actually I Include that max date to my coding,but it is not affect my code.
    link:http://www.aspsnippets.com/Articles/jQuery-UI-DatePicker-Calendar-Example-in-ASPNet.aspx 
  • Mangesh G
    Dinesh 
     
    try CTRL+SHIFT+J an see the errors at the console
    an post here 
  • I tried this but not working, @Mangesh Gaherwar

  • Mangesh G
    $(document).ready(function () {
    var maxdate = new Date();
    $("#<%=txtDate.ClientID %>").datepicker({
    showsTime: false,
    ifFormat: "%d/%m/%y ",
    daFormat: "%l;%M %p, %e %m, %Y",
    align: "BR",
    electric: false,
    maxDate: maxdate,
    singleClick: false,
    displayArea: ".siblings('.dtcDisplayArea')",
    button: ".next()"
    }); 
    1. $(document).ready(function () {  
    2. var maxdate = new Date();  
    3. $("#<%=TextBox1.ClientID %>").dynDateTime({  
    4. showsTime: false,  
    5. ifFormat: "%d/%m/%y ",  
    6. daFormat: "%l;%M %p, %e %m, %Y",  
    7. align: "BR",  
    8. electric: false,  
    9. maxDate: maxdate,  
    10. singleClick: false,  
    11. displayArea: ".siblings('.dtcDisplayArea')",  
    12. button: ".next()"  
    13. });  
    14.   
    15. });  
    This my Current code from http://www.aspsnippets.com/demos/216/
  • Mangesh G
    Share  your working code Dinesh Lemme see share aspx 
  • It not works @ Mangesh Gaherwar.

  • Mangesh G
     Just add this In ur script Dinesh
     
    $(function () {
    var maxdate = new Date();
    $("[id$=txtDate]").datepicker({
    maxDate: maxdate,
    showOn: 'button',
    buttonImageOnly: true,
    buttonImage: 'http://jqueryui.com/demos/datepicker/images/calendar.gif'
    });
    });
     
    Hope it Helps U 
     
    Mark approved if it does 
     
    Reference
     
    http://api.jqueryui.com/datepicker/#option-maxDate 
  • Rajeesh Menoth
    Hi,
     
    Try this code:
    1. var date = new Date("2013-07-15");  
    2.     var currentMonth = date.getMonth();  
    3.     var currentDate = date.getDate();  
    4.     var currentYear = date.getFullYear();  
    5.     $("#datepicker" ).datepicker( "option""maxDate"new Date(currentYear, currentMonth, currentDate));  
    Demo :
     
    http://jsfiddle.net/yLjDH/38/ 
  • Salman Beg
    Hi.
    You can do like this,
     $(function() {   $( "#datepicker" ).datepicker({  maxDate: new Date() }); });

    Or you can achieve this using as below:

    $(function() {   $( "#datepicker" ).datepicker({  maxDate: 0 }); });
     thanks.