Validation
Validating fields (text or other) is crucial for ensuring that data entered by users meets specific criteria or formats and for maintaining data integrity and security.
In Jigx Builder you can use regular expressions (regex) for text validation. They allow for pattern matching and can enforce complex rules for text fields such as email addresses, phone numbers, usernames, passwords, and more. When applied to text validation, regex can be used to check if the input text matches the desired format. If it is not valid, an invalid message is displayed.
In Jigx you combine a JSONata expression with a Regex expressions to create a validation pattern and provide a message if the pattern does not match.
Creating the validation expression:

JSONata expression -
[email protected]Regex expression -
/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/Validation message -
not an email
Combine the three above to validate an email address in the text-field component.
- type: component.text-field
instanceId: email
options:
label: Email
errorText: =$contains(@ctx.components.email.state.value, /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/) ? '' :'not an email'
Regex and JSONata Expression examples
Here are some common validation expressions to create and use for text field validation.
+271234556789
Typically 13-16 digits, with spaces or dashes optional, and includes checks for Visa, MasterCard, American Express, and Discover. 1111-1111-1111-1111 or 1111 1111 1111 1111
5-digit codes, e.g. 10036
XXX-XX-XXXX
AA123456C
23/07/2024
03/28/2023
25 July 2024
2024/08/30
111,25
12:15 AM or 08:45 PM
example.com or https://example.com
978-1-4302-1998-9
JohnSmith
John Smith
56575 76 6
See Also
Last updated
Was this helpful?