[英]Date Range Picker - IsInvalidDate / IsCustomDate
I currently am using DateRangePicker by http://www.daterangepicker.com and have the following code for my project : 我目前正在使用http://www.daterangepicker.com的 DateRangePicker,并在我的项目中使用以下代码:
<form name="calform" action="res_info.php">
<div>Checkout<input type="text" name="checkout"/></div>
<script type="text/javascript">
$(function() {
isInvalidDate: function(date) {
if (date.format('YYYY-M-D') == '2017-11-12') {
return true;
}
}
$('input[name="checkout"]').daterangepicker({
singleDatePicker: true,
"locale": {
format: 'YYYY-M-D'
}
},
function(start, end, label) {
var years = moment().diff(start, 'years');
});
$('.calendar.right').show();
});
</script>
<div> <input type="submit" value="Submit"></div>
</form>
But for some reason , isInvalidDate
function doesn't work at all. 但是由于某种原因, isInvalidDate
函数根本不起作用。 Please Help. 请帮忙。
isInvalidDate appears to be a method of daterangepicker
. isInvalidDate似乎是daterangepicker
的方法。 As your code currently goes, that method is outside of scope of the daterangepicker
object/function. 在您的代码当前运行时,该方法超出了daterangepicker
对象/函数的范围。
You'll need to place it inside like so: 您需要像下面这样放置它:
$('input[name="checkout"]').daterangepicker({
singleDatePicker: true,
"locale": {
format: 'YYYY-M-D'
},
isInvalidDate: function(date) {
if (date.format('YYYY-M-D') == '2017-11-12') {
return true;
}
}
});
Additionally, it looks like the code will still be malformed. 此外,代码看起来仍然会格式错误。 You have a, what i would consider random, function in the daterangepicker
object. 您在daterangepicker
对象中有一个我认为随机的功能。 I'd read the documentation, to get a better understanding of the use of that function. 我将阅读文档,以更好地了解该功能的使用。
http://www.daterangepicker.com/#options http://www.daterangepicker.com/#options
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.