首页 > 代码库 > datepicker日历控件使用

datepicker日历控件使用



<script type="text/javascript"> $(function () { $("[id$=‘txtBeginTime‘]").prop("readonly", true).datepicker({ defaultDate: "+1w", changeMonth: true, dateFormat: "yy-mm-dd", maxDate: new Date(), onClose: function (selectedDate) { $("[id$=‘txtEndTime‘]").datepicker("option", "minDate", selectedDate); } }).focus(function () { $(this).val(‘‘); }); $("[id$=‘txtEndTime‘]").prop("readonly", true).datepicker({ defaultDate: "+1w", changeMonth: true, dateFormat: "yy-mm-dd", maxDate: new Date(), onClose: function (selectedDate) { if (selectedDate != "") { $("[id$=‘txtBeginTime‘]").datepicker("option", "maxDate", selectedDate); $("[id$=‘txtEndTime‘]").val($(this).val()); } } }).focus(function () { $(this).val(‘‘); }); }); </script>



解决使用控件后,验证脚本失效的问题


$("[id$=‘txtDate‘]").prop("readonly", true).datepicker({                defaultDate: "+1w",                changeMonth: true,                dateFormat: "yy-mm-dd",                maxDate: new Date(),                onClose: function (selectedDate) {                    this.focus();  //解决parsley.js验证失效的问题                    this.blur();                }            });

 

 

datepicker日历控件使用