In Formcentric, you can use JavaScript in the calculated value form element to process user input automatically. This means you can perform calculations in real time, based on values that have been entered into the form, such as the total price for a purchase order. This price is calculated automatically from the number of products selected and their unit prices.
Apart from calculating values, you can also use JavaScript to perform dynamic validations. As one example, you can use this functionality to link together the input from various form elements – such as a validation function that only allows a successful newsletter subscription if users are at least 16 years old.
The article Using JavaScript to validate a newsletter subscription shows you how to ensure that individuals can only subscribe to your newsletter if they are at least 16 years old. The guide explains how the validation works, which form elements you will need and how the JavaScript code is integrated with your form.
The article Using JavaScript to validate and link form elements explains how you can implement user-defined checks, link user input together and perform calculations. The guide offers several practical examples, such as age checks or the verification of location and postcode.
The article Calculated value and JavaScript: creating a Paint Calculator shows you how to combine the ‘calculated value’ form element with JavaScript. Using the example of a calculator for pricing paint, the article shows you how to work out the amount of paint needed and the total cost, based on the area to be painted and the paint chosen.