0

I'm using datetimepicker plugin. I want the default input field should be empty instead of showing the current date.

I have tried this so far.

autoUpdateInput": false and "defaultDate": "", these are not working.

<div class="input-group  date">
    <input type="text" name="dates" class="form-control daterange" />              
</div>

$('.daterange').daterangepicker({   
         //"autoUpdateInput": false,
         
        "locale": {
            
            "container": "#CalModal",
            "defaultDate": "",
            "format": "MM/DD/YYYY",
            "separator": " / ",
            "customRangeLabel": "Custom",
            "monthNames": [
                "January",
                "February",
                "March",
                "April",
                "May",
                "June",
                "July",
                "August",
                "September",
                "October",
                "November",
                "December"
            ],
         }      
    });
Saravana
  • 3,389
  • 4
  • 21
  • 37
  • 1
    There are plenty of jquery datetime pickers available. To which specific plugin are you referring to? – Giorgos Betsos Dec 16 '20 at 08:30
  • Try setting it to null instead of "". If that doesn't work, does this help? https://stackoverflow.com/questions/36251020/setting-date-range-picker-start-date-to-blank Maybe $(this).val(''); if this is the input element after the dom is loaded? – react_or_angluar Dec 16 '20 at 08:37
  • '$('.daterange').val('')'. not a proper solution. because my data is will load in the backend. `val(' ')` only clear the input field is empty. – Saravana Dec 16 '20 at 09:35
  • In this case if you have `val(' ')` , you can take the value from textbox after selecting the date range and store it in hidden field. And then on button click you can send this hidden field's value to your backend/server logic. – Rohan Rao Dec 16 '20 at 10:20

1 Answers1

0

put something like this $('.daterange').val('') after your code

M.G
  • 1,061
  • 9
  • 19
  • '$('.daterange').val('')'. not a proper solution. because my data is will load in the backend. `val(' ')` only clear the input field is empty. – Saravana Dec 16 '20 at 09:35