The Bulk Validation package allows you to validate a group of input elements. The package functions check a group of input elements and make sure that each individual input element is validated according to its specified validation type.
When adding or removing input elements on your site, you don’t need to change the code that validates your inputs. You can simply add the new input element to the group, or remove the unwanted input element from the group.
Note: This package is for user input frontend validations only, and should not be used as a replacement for backend validation or authentication of sensitive data.
Before using the package, set up the following:
The following public files are included in the package:
This file contains an array with all supported input types to be validated by the package. You can see a list of all input types here.
Note that the input elements below are not supported for this package since they have no inherent validity indicator, and can’t be checked for validity.
The $w.RichTextBox element is also not supported for this package.
This file contains a function for validating all input elements in a group or a parent container element. The function in this file can be used in your backend/page/public code by importing it with the following syntax:
1
Note that only exported functions that you can use in your site are listed here.
validateInputs()
Recursively loops through each child (input element) of a group or parent container and checks whether the inputs are valid. The function logs each input element's status and returns an object with the validation results.
1
parent
: A group of input elements, or a parent container element that contains children input elements.inputTypesToValidate
: Supported validation input element types.The status of the bulk input validation, as well as the status and error messages of the individual input components. If all inputs in the group or parent container element are valid, the bulk input validation is valid. If one input in the group or parent container element is invalid, the bulk input validation is invalid.
This section demonstrates how to use the package functions to implement a bulk input validation on multiple inputs when a user clicks a submit button.
Follow the steps in the Setup section.
Add a submit button element to your site.
Import the validateInputs()
function from the package:
1
Add an onClick()
event handler to your submit button. Use the async function to wait for the validation result object to return. In the event handler, call validateInputs()
with the parent element, and log the result object.
1
Check to see if the validation result object is valid.
1.1
input, userInput, validity, validation, bulkValidation