Presented by the Government of Brunei Darussalam

Identifying Government Websites

Official website links end with .gov.bn
Sites with .gov.bn are official government websites of Brunei Darussalam. See trusted websites.

Secure websites use HTTPS
Look for a lock (Lock Icon) or https:// as an added precaution. Share sensitive information only on official, secure websites.

How to Set Regular Expression (Regex) Validations with AI

Some fields in your form, such as Textbox, can be given extra rules to ensure that the information entered by respondents follows a specific format. This is done using Regular Expressions (Regex). With FormBN, you can also use AI assistance to generate these rules automatically.

In this example, we will use a Staff Registration Form, where the Full Name field should only contain letters and spaces.

Steps to Set Regular Expression (Regex) Validations with AI: -

  1. Open your form (Staff Registration Form) and expand Form Content to see the list of fields.
1
  1. Right-click on the Full Name (Textbox) field and click Create.
2
  1. Select Validation.
3
  1. Enter a title for your validation (e.g. Full Name Validation) and then, click Save.
4
  1. After saving, right-click on the Validation you just created, and select Create.
5
  1. Choose Regular Expression Validation.
    • Note: You will see two options — Regular Expression Validation and Global Regular Expression Validation. For this example, choose Regular Expression Validation.
6
  1. Enter a title for the Regex rule (e.g. Full Name: Letters Only).
7
  1. Choose how to set the validation rule on the Regular Expression:
    • If you already know the Regex, type it directly (e.g. ^[A-Za-z ]+$ for letters and spaces only).

    • If not, click Get Regex Suggestion.

      • Enter a short instruction (prompt), e.g., “Full name should only accept letters and spaces”.

      • Click Go to let AI generate a Regex for you.

8
  1. Review the AI-generated Regex and either:
    • Accept it to apply the rule, or

    • Reject it if it does not meet your requirement.

Note: You will also see an Error Message box. This is optional, but it is good practice to enter a short, clear message (e.g., “Please enter a valid name using letters and spaces only”) so respondents understand what went wrong.

9
  1. Once you have finished setting the Regex validation (and added an error message, if required), click Save to apply the rule.
10

Example Result: -

After saving the validation, here is how the Full Name field will behave:

Case 1: Valid input

  • If a respondent types “Siti Aminah”, the field accepts the entry without any error.
11

Case 2: Invalid input

  • If a respondent types “Siti Aminah 123”, the field displays a validation error and does not allow submission until the numbers are removed.
12

Connect with us


E-Government National Centre, Brunei Darussalam

© Copyright 2025 E-Government National Centre, Government of Brunei Darussalam.