Atara
Atara

Reputation: 3569

jQuery Datepicker: non-date value

In my project, I have a simple datePicker, and another option to select range-of-days and I display chart according to the selected date(s).

when the user select a date, all works well. but when the user select range-of-days, I want to display in the datePicker-text-box "(manual selection)".

How can I display my text in the datepicker text-box ?

My code:

$( "#datepicker" ).datepicker({ 
  minDate: new Date(2016, 2 - 1, 11),
  maxDate: new Date(2016, 2 - 1, 19),
  defaultDate: new Date(2016, 2 - 1, 13),

  onSelect: function(dateText, inst) {
              DispalyChart(dateText);
  }
 });

 $( "#datepicker" ).datepicker( "setDate", new Date(2016, 2 - 1, 13));

Upvotes: 0

Views: 77

Answers (1)

Is it something like appending placeholder to textbox...? please refer below code:

<input type="text" class="datepicker" placeholder="Start date:" />
<script>
  $(".datepicker").datepicker({
    onSelect: function(arg) {
      $(this).val($(this).attr("placeholder") + arg);
    }
  });
</script>

Upvotes: 2

Related Questions