Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear the value of bootstrap-datepicker

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 the datepicker when a button is clicked. I have checked the API but cannot find anything on clearing/resetting the datepicker. Any help is welcome

like image 224
user2906420 Avatar asked Mar 05 '14 11:03

user2906420


People also ask

How do you make a datepicker empty?

Set datetimepicker FORMAT property to custom. set CUSTOM FORMAT property to empty string " ". set its TAG to 0 by default.

How do I unbind a datepicker?

You can try the enable/disable methods instead of using the option method: $("#txtSearch"). datepicker("enable"); $("#txtSearch"). datepicker("disable");


1 Answers

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"); }) 
like image 133
Needpoule Avatar answered Sep 21 '22 10:09

Needpoule