JQuery: datepicker - Calendar activated by icon and date field at the same time

I already looked around, but could not find the exact solution / problem that I have now.

All I want is to show the calendar by clicking on the calendar icon AND from the text box that displays the date when you select the date. Right now, having tried different properties, I can only show the calendar with one or the other, but not both: the icon and the field.

This is the code I use to activate it through the icon:

$("#datepicker").datepicker({
   showOn: 'button',
   buttonImage: 'images/icon-calendar.gif',
   buttonImageOnly: true,
   changeMonth: true,
   changeYear: true,
   showAnim: 'slideDown',
   duration: 'fast'
});

Is there a way to show the calendar by clicking the icon and field?

Thank.

+3
source share
3 answers

try setting: showOn: 'both'

+1
source

, "":

$("#datepicker").datepicker({
 showOn: 'both',
 buttonImage: 'images/icon-calendar.gif',
 buttonImageOnly: true,
 changeMonth: true,
 changeYear: true,
 showAnim: 'slideDown',
 duration: 'fast'
});

.

+3

Give a date picker to the identifier and try the following:

<input type="text" name"whatever" id="datepickerfield" />

For the field:

$("#datepickerfield").datepicker({
 showOn: 'button',
 buttonImage: 'images/icon-calendar.gif',
 buttonImageOnly: true,
 changeMonth: true,
 changeYear: true,
 showAnim: 'slideDown',
 duration: 'fast'
});
+1
source

Source: https://habr.com/ru/post/1741974/


All Articles