0

我需要 jquery 日期选择器的帮助 我有两个文本框一个用于签入,另一个用于签出...我希望 1 天添加到结帐框中这是我的代码,我无法提前 1 天在签出框中获取日期...请帮助

    $("#CheckInDatePicker").datepicker({
        defaultDate: "+1w",
        minDate: 0,
        changeMonth: true,
        showOn: "button",
        buttonImage: "/Images/Base/calander.png",
        numberOfMonths: 2,
        showButtonPanel: true,
        buttonImageOnly: true,


        onSelect: function (selectedDate) {
            var minDate = $(this).datepicker('getDate');
            if (minDate) {
                minDate.setDate(minDate.getDate() + 1);
            }
            $("#CheckOutDatePicker").datepicker("option", "minDate", minDate || 1);
            }
4

4 回答 4

1
 $(document).ready(function() {
    $( "#saledate" ).datepicker({  maxDate: "+1d", dateFormat: 'dd/mm/yy' }); 
    $("#saledate").datepicker("option","defaultDate", "<?=date("d/m/Y");?>");
 });

试试这个代码 #saledate 是 datepicker 字段的 id。

于 2017-01-04T10:57:49.937 回答
0

试试这个..并在尝试之前清除浏览器缓存..

onSelect: function(dateValue, inst) {
            $('#CheckOutDatePicker').datepicker();              
            var date2 = $('#CheckInDatePicker').datepicker('getDate', '+1d');                
            $('#CheckOutDatePicker').datepicker('destroy');
            date2.setDate(date2.getDate() + 1); 
            $('#CheckOutDatePicker').datepicker({
                minDate: date2,
                dateFormat: "yy-mm-dd",
                onSelect: function() {
                    //Do whatever you want to do
                }
            });   
        }

在http://jsfiddle.net/writetobhuwan/T6hPR/1/上查看

于 2013-04-01T13:36:04.000 回答
0
$("#CheckInDatePicker").datepicker({
    defaultDate: "+1w",
    minDate: 1,
    changeMonth: true,
    showOn: "button",
    buttonImage: "/Images/Base/calander.png",
    numberOfMonths: 2,
    showButtonPanel: true,
    buttonImageOnly: true,

change the minDate 你的一天延长一天

于 2013-04-01T13:02:29.263 回答
0
/*DATE PICKER FUNCTION START*/
    var today = new Date();
    $(function() {
        $( "#date_from" ).datepicker({
            defaultDate: "+0w",
            changeMonth: true,
            dateFormat: "yy-mm-dd",
            numberOfMonths: 1,
            onSelect: function( selectedDate ) {

                if($( "#date_to" ).val() == ""){
                    /*console.log(selectedDate);
                    var dateString = selectedDate; // date string
                    var actualDate = new Date(dateString); // convert to actual date
                    var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()+1); // create new increased date
console.log(actualDate.getMonth());
                    // now extract the bits we want to crete the text version of the new date..
                    var newDateString = (newDate.getFullYear()+'-'+newDate.getMonth()+'-'+newDate.getDate());
                    console.log(newDateString);*/
                    $( "#date_to" ).datepicker( "option", "minDate", selectedDate );

                }
            }
        });
        $( "#date_to" ).datepicker({
            defaultDate: "+1w",
            changeMonth: true,
            dateFormat: "yy-mm-dd",
            numberOfMonths: 1,
            minDate: "+1d",
            onSelect: function( selectedDate ) {
                $( "#date_from" ).datepicker( "option", "maxDate", selectedDate );
            }
        });
    });
    /*DATE PICKER FUNCTION END*/

更改您想要的字段名称......我希望这会奏效

于 2013-10-30T14:11:17.650 回答