SurveyGizmo's CustomScript Action now supports the LUA programming language.
Legacy Custom Scripting Language Deprecation Plans
New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
In the long term, Legacy Custom Scripting Actions will be switched to read-only. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.
While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.
This script will perform age verification based on the date of birth entered in a Date question. The qualifying age can be set in the script (18 years old, 21 years old, etc.) and if the user is not old enough, they will be disqualified. If they are old enough, the script does nothing and allows them to move forward through the survey. You can also customize the disqualification message in the script.
The script example below will accept an age limit of 0 to 55 years old and will disqualify your response if the date range equals less than 21 years of age from the current date.
textboxqid = 2 -- Text field Question ID
agelimit = 21 -- Age Limit - below this age (in years) will be disqualified
qualifiedpage = 4 -- Page ID to jump to if qualified to continue in survey
-- Disqualification Message
msg = "I'm sorry, you are not old enough to take this survey. Thanks for your time!"
birthdate = getvalue(textboxqid)
birthdate_unix = strtotime(birthdate)
--If not using DD/MM/YYYY validation this section of code can be optionally removed
if birthdate_unix == false then
birthdate_unix = strtotime(str_replace("/", "-", birthdate))
end
-- End DD/MM/YYYY condition ---
today = date("Y-m-d")
today_unix = strtotime(today)
validdate_unix = strtotime('-'.. agelimit .. 'years', today_unix)
if (birthdate_unix > validdate_unix) then
disqualify(msg)
else
jumptopage(qualifiedpage)
end
Required Customizations
In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey.
textboxID - This variable will indicate the question ID of the date validated textbox where you collect birth date.
agelimit - The age limit you would like to set. Any response received with an age limit below this age (in years) will be disqualified. For example, if you do not want anyone under the age of 30 to fill out your survey, you'd want to use: agelimit = 30
qualifiedpage - The page to jump to when respondents are qualified.
Optional Customizations
msg - This message will display to the respondent who does not meet your age limit. You can choose to customize this further or leave the message as is.
Various Date Formats
The date question supports the following formats. This script will work with any of these formats.