How to limit date picker range?

  • 6 October 2017
  • 5 replies
  • 134 views

Badge +2

Hello all!

I was curious if there is a way to limit the date/time control to only allow dates to be selected for past 7 days and current day, no further forward or back?

Thanks! 


5 replies

Badge +7

Not on selection, but you can define a validation rule that prevent the form to be submitted if date is not in your range.

Badge +2

Found a javascript solution!

NWF$('#' + datebook).datepicker('option',{minDate: '-7d',maxDate: Current Date});

Thanks for the help! 

Badge +6

Thanks for the solution.

But this is a part of jQuery UI DatePicker , am i right ? To make use of your code one must have or refer the jQuery UI js file.

Badge +3

I was able to accomplish like this:

Set date picker min val to today:

NWF$(document).ready(function(){

NWF$.datepicker.setDefaults({minDate: new Date()});

});

this sets all datepickers. If I want to set just a single date picker to set the min date to be the date of another datepicker selection it doesn't work:

NWF$("#"+ minDval).on('change',function(){
var minD=NWF$("#"+ minDval).val();
var retD=NWF$("#"+rDval);

retDval.datepicker.setDefaults({minDate: new Date(minD)});
});

any ideas?

Badge

Hi @bcobra ,

 

Sorry my english isn't very well but I solved your question.

 

I did it to put min date to specific date picker in nintex forms.

NWF$('#' + varFechaDonacion).datepicker('option',{
minDate: new Date(),
});

 

Where "varFechaDonacion" is variable javascript

Reply