Note that there are some explanatory texts on larger screens.

plurals
  1. POSet ui datepicker max/minDate on the fly
    primarykey
    data
    text
    <p>Thought it would be more easier than it is. Task:</p> <p>1)disable future days. (Set maxDate as today - done)</p> <p>2)from js variable get date and set it as a minDate on the fly - <strong>how?</strong></p> <p>main function (which I use for few pages):</p> <pre><code>jQuery( function($){ $('#datepicker').datepicker({ onSelect: function(dateText, inst){calendarOptions(dateText);}, // beforeShow: function() {$("#datepicker").datepicker( "option", "minDate", curdate ).next('button').text('Kalendārs').button({icons:{primary : 'ui-icon-plus'}})}, showOn: "button", dateFormat: 'dd.mm.yy', prevText: '&amp;laquo;', nextText: '&amp;raquo;', monthNames: ['Janvāris','Februāris','Marts','Aprīlis','Maijs','Jūnijs', 'Jūlijs','Augusts','Septembris','Oktobris','Novembris','Decembris'], monthNamesShort: ['JAN', 'FEB', 'MAR', 'APR', 'MAI', 'JUN', 'JUL', 'AUG', 'SEP', 'OKT', 'NOV', 'DEC'], dayNamesMin: ['S', 'P','O','T','C','P','S'], firstDay: 1, maxDate: calendarMaxDate() }).next('button').text('Kalendārs').button({icons:{primary : 'ui-icon-plus'}}); } ); </code></pre> <p>And then comes js code for page I want to edit now:</p> <pre><code>function calendarMaxDate(){//disable future days var date = new Date(); var currentMonth = date.getMonth(); var currentDate = date.getDate(); var currentYear = date.getFullYear(); return new Date(currentYear, currentMonth, currentDate) //return null; // set to default } function calendarOptions(dateText){ // sets selected date to 'external' input field autofield_date.setValue(dateText); } jQuery( function($){ // calls function before ui datepicker button is pressed $('.ui-datepicker-trigger').click(function() { alert(autofield_dekl.getValue()); MinDate(); }); } ); function MinDate(){ //pass curdate value as'minDate' to calendar on the fly jQuery( //not sure about this part function($){ //without onload function it throws an error: $("#datepicker") is null $("#datepicker").datepicker( "option", "minDate", curdate ).next('button').text('Kalendārs').button({icons:{primary : 'ui-icon-plus'}})//; } ) alert(curdate); } </code></pre> <p>function MinDate() works only in the first time when the button has been pressed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload