javascript - Date Range Picker - IsInvalidDateIsCustomDate - Stack Overflow

I currently am using DateRangePicker byand have the following code for my project : <form name=&qu

I currently am using DateRangePicker by and have the following code for my project :

<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. Please Help.

I currently am using DateRangePicker by http://www.daterangepicker. and have the following code for my project :

<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. Please Help.

Share Improve this question edited Aug 7, 2017 at 16:06 Aqua Wong asked Aug 7, 2017 at 15:57 Aqua WongAqua Wong 311 gold badge1 silver badge3 bronze badges 1
  • Where or how are you trying to use the function isInvalidDate? – Amit Joshi Commented Aug 7, 2017 at 16:05
Add a ment  | 

1 Answer 1

Reset to default 8

isInvalidDate appears to be a method of daterangepicker. As your code currently goes, that method is outside of scope of the daterangepicker object/function.

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. I'd read the documentation, to get a better understanding of the use of that function.

http://www.daterangepicker./#options

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743884838a4523840.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信