mai-kel
Nintex Newbie

Set date (end date = start date)

Jump to solution

Hi everybody,

I have a form where the user is asked to give a start and an end date.

After giving the start date, the end date should be prepopulated with the start date, whereas this should still be editable.

Cheers,

mai-kel

Tags (2)
0 Kudos
Reply
5 Replies
lakshminarayana
Nintex Newbie

Re: Set date (end date = start date)

Jump to solution

Hi ‌,

Try this JS code.

NWF$('#'+Date1).change(function()
{
var date=NWF$('#'+Date1).datepicker('getDate');
NWF$('#'+Date2).datepicker('setDate', date);    
});

Thanks,

Lakshmi C

View solution in original post

Reply
mai-kel
Nintex Newbie

Re: Set date (end date = start date)

Jump to solution

Great. That's it! Thanks a lot buddy!  

Reply
emilytan
Nintex Newbie

Re: Set date (end date = start date)

Jump to solution

Hi Lakshmi C 

I'm new in Nintex. Can you please provide the steps to apply this JS code in Nintex form?

I've tried paste the code in Setting - Form > Custom JavaScript Box 

And change the code as below but it doesn't work.

NWF$('#'+VisitStartDateTime).change(function()
{
var date=NWF$('#'+VisitStartDateTime).datepicker('getDate');
NWF$('#'+VisitEndDateTime).datepicker('setDate', date);   
});

Thanks,

Emily

0 Kudos
Reply
mai-kel
Nintex Newbie

Re: Set date (end date = start date)

Jump to solution

Step 1:
Create first date / time control.
Go to advanced settings and configure
- "Store Client ID in JavaScript variable" -> yes
- "Client ID JavaScript variable name" -> Date1


Step 2:
Create (second) date / time control.
Go to advanced settings and configure
- "Store Client ID in JavaScript variable" -> yes
- "Client ID JavaScript variable name" -> Date2

Step3:
Go to form settings.
Open "Advanced", insert the following code into "Custom JavaScript Includes":

NWF$('#'+Date1).change(function()
{
var date=NWF$('#'+Date1).datepicker('getDate');
NWF$('#'+Date2).datepicker('setDate', date);    
});

Reply
emilytan
Nintex Newbie

Re: Set date (end date = start date)

Jump to solution

It worked Michael, thanks.

Reply