Copy Submission Date Example

This form example uses JavaScript to copy the calendar date value that the user inputs in the initial submission creation step for using that value elsewhere in the form. This saves the user from having to enter the value again.

Below is the JavaScript code in question and it must be added to the 'Data' tab in the 'Custom Default Value' section of the field that you want to receive the date value.

Example JavaScript Code:

let target_selector = '#date_start'; // change the selector
let reg = /(^\d{1,})\/(\d{1,})\/(\d{4}$)/;
let target_val = document.querySelector(target_selector)?.value || '';
let reg_r = target_val?.match(reg);
if(!!reg_r){
let date = `${reg_r[3]}/${reg_r[2]}/${reg_r[1]}`; // convert 'dd/MM/yyyy' to 'yyyy-MM-dd'
value = new Date(date)?.toISOString() || '';
}


To test this example you must make this an active form with a single date picker and at least one approval stage. To test, use the form and you will see that the date you choose during the submission creation step will be copied to the two fields below.

Was this article helpful?
Cancel
Thank you!