Question

I have a datepicker that works fine in Firefox, but in Internet Explorer (10) minDate, maxDate and beforeShowday doesn't work. Anyone who has had the same problem? What was your solution?

myJS.js

$(document).ready(function () {
    $("#datepicker").datepicker({
        monthNames: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
        dayNamesMin: ["Sön", "Mån", "Tis", "Ons", "Tors", "Fre", "Lör"],
        dateFormat: "yy-mm-dd",
        firstDay: 1,
        selectWeek: true,
        beforeShowDay: $.datepicker.noWeekends,          
        maxDate: "+30D",
        minDate: 0,
        closeOnSelect: false            
    });    
});

asp.net

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css" />

<asp:TextBox ID="datepicker" runat="server" CssClass="textbox" ReadOnly="False" AutoPostBack="True" Width="200px" OnTextChanged="datepicker_TextChanged" Height="22px"></asp:TextBox>
Was it helpful?

Solution

You shouldn't use a text to set the max or min date. Each browser interprets them differently.

Try doing:

var date= new Date(); date.setDate(date.getDate()+30);

minDate: date , maxDate: -1

OTHER TIPS

 $(document).ready(function () {
    $("#datepicker").datepicker({
        monthNames: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
        dayNamesMin: ["Sön", "Mån", "Tis", "Ons", "Tors", "Fre", "Lör"],
        dateFormat: "yy-mm-dd",
        firstDay: 1,
        selectWeek: true,
        beforeShowDay: $.datepicker.noWeekends,          
        maxDate: "+30D",
        yearStart:1900,
        closeOnSelect: false            
    });    
});             
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top