Skip to main content
Nintex Community Menu Bar

Set Start Date equal to End Date

  • Aug 31, 2017 1:33 AM UTC
  • 3 replies
  • 78 views
  • Translate All

Forum|alt.badge.img+6

I'm working on a form where the start date field should always end date, and set the values equal if the user changes one. The following JavaScript is what I'm trying to use, but getting an error

NWF$(document).ready(function () {
var calStartDate = NWF$('#' + varStartDate);
var calEndDate = NWF$('#' + varEndDate);
//alert(calStartDate.val());
//alert(calEndDate.val());
calStartDate.change(function () {
calEndDate.val = calStartDate.val;
});

calEndDate.change(function () {
calStartDate.val() = calEndDate.val();
});

});

3 replies

Forum|alt.badge.img+9
  • Aug 31, 2017 7:23 AM UTC

to set a value use .val(value) see http://api.jquery.com/val/ and set date field based on other field selection and  

Translate

Forum|alt.badge.img+6
  • Author
  • Aug 31, 2017 1:00 PM UTC

I was able to resolve that specific error, now I'm getting [object Object] in the date field that is being updated by the change event. Do I need to change the format of the value being replaced?

Version 1:
NWF$(document).ready(function () {
var calStartDate = NWF$('#' + varStartDate);
var calEndDate = NWF$('#' + varEndDate);
//alert(calStartDate.val());
//alert(calEndDate.val());
calStartDate.change(function () {
NWF$('#' + varEndDate).val(calStartDate) ;
});

calEndDate.change(function () {
NWF$('#' + varStartDate).val(calEndDate);
});
});

Version 2:
NWF$(document).ready(function () {
var calStartDate = NWF$('#' + varStartDate);
var calEndDate = NWF$('#' + varEndDate);
//alert(calStartDate.val());
//alert(calEndDate.val());
calStartDate.change(function () {
NWF$('#' + varEndDate).val(NWF$('#' + varStartDate)) ;
});

calEndDate.change(function () {
NWF$('#' + varStartDate).val(NWF$('#' + varEndDate));
});
});
Translate

Forum|alt.badge.img+14
  • Scholar
  • Aug 31, 2017 11:24 PM UTC

have you seen this - https://community.nintex.com/message/35103?commentID=35103#comment-34952 ?

at first, you should set date control values like

NWF$('#' + varEndDate).val(calStartDate.val()) ;‍‍

at second, this will only set date part. for time part you need to add extra calls.

follow the link I posted.

‌ ‌ ‌ ‌ ‌ ‌

Translate