iFormBuilder Smart Controls
What's covered:
- What are Smart Controls?
- What is Client Validation?
- What is a Validation Message?
- How do I add Client Validation to an element?
- Troubleshooting the errors with client validation
WHAT ARE SMART CONTROLS?
Smart Controls use JavaScript to add various functions to forms as shown below. They can be used to hide elements, perform skip logic, change data and more.
Click here for more information on smart controls.
WHAT IS CLIENT VALIDATION?
Client Validation allows...
- Form builders to prevent illegitimate data to be uploaded to the server.
- Form builders to set multiple validation criteria on an element.
The client validation value must be true for a particular element to pass validation. This smart control is located on the Element Properties menu (on the right-hand side in form builder).
What is a Validation Message?
The Validation Message helps...
- instruct data collectors as to where the error in their data lies.
- enforce complex criteria within your form.
How do I add Client Validation to an element?
To add Client Validation to your element, please follow the instruction below.
Example: Teachers have to enter students' test results on a form and the score ranges from 0 to 100.
STEP 1. With your form loaded in the Form Builder, highlight the element you want to add the Client Validation to. PLEASE NOTE: In this example, we will be working with a Number element.
STEP 2. On the right-hand menu, scroll down to the Smart Control section.
STEP 3. In the Client Validation field, enter the following: test_results >= 0 && test_results <= 100
This indicates that the number entered by the user must be greater than or equal to 0 and less than or equal to 100.
iFormBuilder Tip: Use || for or and && for and
STEP 4. In the Validation Message field, enter the message you want the user to see if the validation fails. For example: "Please enter a number between 0 and 100"
PLEASE NOTE: Validation messages MUST be wrapped in quotation marks in order to display on the device correctly.
STEP 5. Save your form.
STEP 6. Test the functionality on your device. If a user enters a number that is not in the range from 0 to 100, the Validation Message will be shown upon submitting the record.
PLEASE NOTE: Client Validation will be evaluated whether the field is showing or hiding. Please keep that in mind when you are testing out your forms.
Troubleshooting the errors with client validation
Below are various errors that could occur during data collection, along with the necessary steps for resolution.
Error: missing ; before statement (ZCFormula#1)
This error occurs when there are no double quotations around the client validation message. To address this issue, please enclose the validation message with double quotations.
Error: Unterminated string literal (ZCFormula#1)
This error is triggered if there is a double quotation at the beginning of the client validation message without a corresponding closing quotation. To resolve this error, ensure that you include a double quotation at the end to close the string literal.
Comments
6 comments
When using page-level javascript functions in Client Validation, is it possible to reference other fields on the form? When doing so I get the error "ReferenceError: Can't find variable: x".
Within the page-level javascript function, it seems that I can only resolve the field which I am currently validating.
Hi Guy, would you be willing to share the details of your validation scenario with us? You can either post below, or send us new request through the Help Desk.
Thanks!
Sorry, I had something else interfering - very hard to debug. I neglected to place the enclosing quotes on the validation message. This causes utter confusion until detected. I am deleting my post. Please feel free to remove the follow-ons. Thanks for responding. BTW, you might be amused that my requirement is to make a non-required element required. I am attempting to do that by adding a required checkbox to say that I have chosen to ignore the other field.
Hi
What would be the test to make sure that the number has always one decimal place and between 0 to 30?
Can a client validation reference another question in a form?
Could this be used for text area fields for a minimum ammount of text? for example a user MUST fill in at least 50 characters for that field/form to be submitted?
Please sign in to leave a comment.