日历控件如何固定只能选择14天的数据??超过14天的数据设为禁用? 财富值42

2016-09-27 19:02发布

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <title>jQuery UI Datepicker - Select a Date Range</title>   <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">   <link rel="stylesheet" href="http:/resources/demos/style.css">   <script src="https://code.jquery.com/jquery-1.12.4.js"></script>   <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>   <script>   $( function() {     var dateFormat = "mm/dd/yy",       from = $( "#from" )         .datepicker({           defaultDate: "+1w",           changeMonth: true,           numberOfMonths: 2         })         .on( "change", function() {           to.datepicker( "option", "minDate", getDate( this ) );         }),       to = $( "#to" ).datepicker({         defaultDate: "+1w",         changeMonth: true,         numberOfMonths: 2`请输入代码`       })       .on( "change", function() {         from.datepicker( "option", "maxDate", getDate( this ) );       });       function getDate( element ) {       var date;       try {         date = $.datepicker.parseDate( dateFormat, element.value );       } catch( error ) {         date = null;       }         return date;     }   } );   </script> </head> <body>   <label for="from">From</label> <input type="text" id="from" name="from"> <label for="to">to</label> <input type="text" id="to" name="to">     </body> </html>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答

没人回答,好尴尬

一周热门 更多>