Clear the value of bootstrap-datepicker

前端 未结 10 1881
甜味超标
甜味超标 2020-12-28 12:56

I am using bootstrap-datepicker from here: https://github.com/eternicode/bootstrap-datepicker

version: 2.3.2

I am having trouble to clear the date values of

相关标签:
10条回答
  • 2020-12-28 13:42

    Current version 1.4.0 has clearBtn option:

    $('.datepicker').datepicker({
        clearBtn: true
    });
    

    Besides adding button to interface it allows to delete value from input box manually.

    0 讨论(0)
  • 2020-12-28 13:43

    you have to do it in that way:

    $('#datepicker').datepicker('clearDates');
    
    0 讨论(0)
  • 2020-12-28 13:49

    You can use jQuery to clear the value of your date input.

    For exemple with a button and a text input like this :

    <input type="text" id="datepicker">
    <button id="reset-date">Reset</button>
    

    You can use the .val() function of jQuery.

    $("#reset-date").click(function(){
        $('#datepicker').val("").datepicker("update");
    })
    
    0 讨论(0)
  • 2020-12-28 13:49

    I know its too late to answer, but in my scenario below code was not working.

     $('#datepicker').val("");
     $('#datepicker').val('').datepicker('update');
     $('#datepicker').datepicker('update','');
    

    here is my solution.

     $('#datepicker').val('').datepicker('remove').datepicker();
    

    I did clear datepicker value first then removed datepicker and again reinitialize datepicker. its resolved my problem.

    0 讨论(0)
提交回复
热议问题