>, Flex, Tutorials>Custom script for forms

Custom script for forms

If you want to use your own script in form pages and/or dialogs, add the xsforms Javascript object to “Form pages script (53)” in the code editor.

Related articles

Script for your forms

The xsforms object is supported in Flex only.

The Javascript object has a number of methods that you can use, all methods are optional – i.e. you only need to add the methods that you need. You can ofcourse also add your own functions and you can then call those from any of the standard methods described below.


This is the initialization function that is called when a page or dialog containing a form loads. The parameter “n” is the id of the form. If xsforms exists, it will be called for every form, use the “n” parameter in your script to handle specific forms. For example, the value of “n” will be “contactusform” if called from the Contact page.


This function is called after init() and before the standard form initialization function is called. The standard function e.g. initializes the input elements (date inputs, drop downs and so on), and it adds classes (required fields) based on the forms settings that you have configured in back office.


This function is called after “onbeforeinit”. You can use it to e.g. manipulate inputs and classes after the normal initialization has completed.


If “onvalidate” exists, this function is called before the standard input validation function. You can return false to prevent the form from being submitted, you must return true to make sure that the rest of the functions are called (or else the form will not be submitted). Note that the standard form validation function is called after your own validation function – provided that you return true to indicate that the form may be submitted.


This function is called after form validation has completed but only if the form is ready to be submitted, i.e. if validation was successful. Return true to submit the form or false to prevent the form from being submitted.


If the form is an email form (e.g. the contact us page) then the function aftersendmail() is called after the form has been successfully posted. If you use this function, then the standard function is not executed. The variable “d” is the JSON object that is returned by the standard script.


2021-09-15T17:01:57+02:00 September 14th, 2021|Categories: Customisation, Flex, Tutorials|