iFormBuilder JavaScript Tips & Tricks
What's covered:
What is Page Level JavaScript?
Page Level JavaScript loads user-defined global variables and functions that can be called by a parent form and/or any of the related child forms.
Click here for more information on Page Level JavaScript.
How do I change the format of a date?
To change the format of a date captured by iFormBuilder, please follow the instructions below.
PLEASE NOTE: In the example below we will be changing the format to YYYYMMDD.
STEP 1. From inside your form, click the Page Level JavaScript icon.
STEP 2. Paste in the following JavaScript:
Date.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); // padding
};
d = new Date();
STEP 3. Click Save and then Close.
STEP 4. Add a Text element to your form.
PLEASE NOTE: You can use the Read-Only element as well. Do NOT use the Date element.
STEP 5. In the Dynamic Value field of the element, place the following:
d.yyyymmdd()
STEP 6. Save your form.
STEP 7. Test out the functionality on your form.
PLEASE NOTE: If you want to change the format of the order, update the order in this portion of the Page Level JavaScript: "return (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]) + yyyy; // padding"
Download the below form package to use as an example.
Comments
0 comments
Please sign in to leave a comment.