Skip to main content
Nintex Community Menu Bar
Solved

Year Range issue with Date Picker Control on Nintex Form

  • March 14, 2018
  • 10 replies
  • 297 views

Forum|alt.badge.img+1

Hi,

We have in issue with Date Picker control on Nintex Form.  The year range is displayed on the form is for the last 10 years only. If we select a year it then goes back to another 10 years.  How can I change the year range to display last 100 years by default?

Out Nintex form version is 2.3.3.1 and we run it on SharePoint 2013.

Thanks

Tony

Best answer by emha

you can configure it, but only with a javascript

NWF.FormFiller.Events.RegisterAfterReady(function(){
   NWF$('#' + dateCtrl).datepicker('option',{
       yearRange: "-50:+50",
   })
})

10 replies

Forum|alt.badge.img+14
  • Scholar
  • Answer
  • March 15, 2018

you can configure it, but only with a javascript

NWF.FormFiller.Events.RegisterAfterReady(function(){
   NWF$('#' + dateCtrl).datepicker('option',{
       yearRange: "-50:+50",
   })
})

Forum|alt.badge.img+1
  • Author
  • March 15, 2018

Thanks so much.  It worked for me.


Forum|alt.badge.img+14
  • Scholar
  • March 15, 2018

Great!

Please mark the question answered.


Forum|alt.badge.img+7
  • May 7, 2018

This is exactly what I needed!

In my case, I have a large form with a number of Date Picker controls. So, I actually made a slight change to the code to make it work for all Date Picker controls across the form, and not require any setting changes to the individual controls.

I've replaced this:

NWF$('#' + dateCtrl)

with this:

NWF$('.nf-date-picker')

Thank you once again Marian Hatala‌!


Forum|alt.badge.img+3
  • Rookie
  • August 27, 2018

Ok, so how about those of us using responsive forms? I need a date of birth field, and going back only 10 years is a huge problem. 


Forum|alt.badge.img+14
  • Scholar
  • August 27, 2018

unfortunatelly, with responsive forms you're out of luck...


Forum|alt.badge.img+4
  • Rookie
  • October 3, 2019
Newbie question...do I just copy and paste the above code into Settings > Custom JavaScript ? I've tried and nothing happens.

Forum|alt.badge.img+1
  • Rookie
  • November 20, 2019

You need to link the function to your action, unless you use @chaddavis  solution to apply it to every date picker action on your form.

To use the function on a single action as @emha suggested do the following:

  • Open your Date Picker action
  • go to Advanced
  • Change 'Store Client ID in JavaScript variable' to Yes
  • type 'dateCtrl'.

You can type the ID name you like,  but you have to make sure you update the function as well.

NWF.FormFiller.Events.RegisterAfterReady(function(){
   NWF$('#' + dateCtrl).datepicker('option',{
       yearRange: "-50:+50",
   })
})

 

Hopefully this helps


JohanEsteban92

con esta funcion puesta en la zona de javascripr de la configuracion del formulario me funciona perfecto, hice un par de ajustes


NWF$(document).ready(function() {  
NWF$('.nf-date-picker').datepicker('option',{
       yearRange: "-50:+50",
   })
})

  • Novice
  • January 20, 2022

How are you adding JS to a responsive form or is this for classic only???