Below is a list of commonly used scripts. Scripts here are intended to easily copy and paste into your applications for simplifying specific tasks. You may need to alter component names (API Keys) to fit your specific forms.
Format a date in a Text Component
If you are looking for basic, manual date input, using a Text Component is often the simplest approach. It can be helpful to assign an input mask to the component (99/99/9999) and a minimum length of 8.
Calculated Value Script
//Take in a date string and insert slashes if(data.dob && data.dob.length == 8) { var userDate = data.dob; value = userDate.slice(0,2) + '/' + userDate.slice(2,4) + '/' + userDate.slice(4,8); } else value = data.dob;
Capture a date based on signature input to a Text Component
If you wish to capture a date based on a user making a mark in a signature component, add a Text Component with an API Key of dateSigned and mark it disabled to prevent user manipulation of the field. Add a Signature Component with an API Key of signature.
Calculated Value Script
//Assign a system calculated date based on data entry in another component. var current = new Date(data.dateSigned); if(data.signature && current.toString() === 'Invalid Date') { var d = new Date(); value = d.toLocaleDateString(); } else value = data.dateSigned;