top of page

Moji5 Knowledgebase

Using the basic validation features

Problem

You want to apply the following validation to your form:

  • Validating numbers against a certain fixed range

  • Validating dates against a certain fixed range

  • Validating text against a certain pattern

  • Validating text strings against a certain length

  • Mandatory/compulsory field validation

  • Duplicate data validation


Solution

Setting up the sample:

1. We used form from previous called "Sample Invoice"

2. Create three new fields:

  • Invoice Date (Date & time field)

  • Invoice Amount (money field)

  • Invoice ID (text field)


Validating numbers against a certain fixed range:

1. Let us say for instance that your "Invoice Amount" field must be a value between

$50.00 and $1,000,000.00

2. To create a simple validation check for this field, click on the settings icon (in the

shape of a gear. This is highlighted in red below) next to the "Invoice Amount"

field



3. In the ensuing page, key in the numerical value range as between 50 and

1000000 (without the commas)



4. Save your changes, and try to run/publish your form.

5. When you attempt to key in a value bigger than 1,000,000 or smaller than 50 in

the Invoice amount field on your form, you will see an error message (as shown

below)



Please take note that even if you create a range validation check as shown above, it will still not automatically check for empty values. This means you are still allowed to leave the field completely empty. To apply an additional "Compulsory field" check, please see the "Mandatory/Compulsory field validation" section below.



Validating dates against a certain fixed range:

1. Let us say for instance that your "Invoice date" field must be a value between

4/November/2024 and 31/Dec/2024.

2. To create a simple validation check for this field, click on the settings icon (in the

shape of a gear) next to the "Invoice date" field.

3. In the ensuing page, key in the date range as 4/November/2024 and 31/Dec/2024

respectively in the "Date value range" field.



4. Save your changes, and try to run/publish your form.

5. When you attempt to key in a date earlier than 4/November/2024 or a date later than

31/Dec/2024, you will see an error message (as shown below).



If you want to achieve dynamic date range validation (when your date range is dynamic instead of fixed), such as comparing the keyed in date against the current date or a date from another field, please see the "Validating dates dynamically" article.


Validating text against a certain pattern:

1. Let us say that the "Invoice ID" you have to key in must follow this particular format - "INVXXXXXXX" where the first 3 letters must be "INV", followed by 7 digits ("X" must be a number). For instance, INV1234567 or INV0000001 would be valid data

2. To validate the text field against this pattern, we must specify the pattern in regular expression format.


Regular Expressions are a popular international standard for specifying patterns of any complexity. A simple search for "Regular Expressions" under Google will turn up many reference sites. One such site can be found here:


3. The regular expression to match "INVXXXXXXX" is: INV[0-9]{7}

4. Click on the settings icon next to the "Invoice ID" field. In the "Input mask" field, key in the regular expression shown above.



5. Save your changes and then publish and run the form

6. When you type in any value that does not conform to this pattern, you will see the error message shown below.



Validating text strings against a certain length:


1. Now let us say we need the "Invoice ID" field to be a maximum of 10 characters. Although you have specified a validation pattern for the "Invoice ID" field in the previous example, it does not restrict the length of data that you can key into the "Invoice ID" textbox.

2. To create text limit validation, click on the settings icon next to the "Invoice ID" field, and specify "10" in the "Max characters" field.



3. Save your changes, and then publish and run the form.

4. You now find that you cannot key in more than 10 characters into the "Invoice ID" textbox.


Mandatory/Compulsory field validation


1. Now let us say you need to make sure that the Invoice ID is filled in by the user before allowing him or her to save the form. In other words, you need to make some of the fields on the form compulsory.

2. To create mandatory/compulsory field validation, click the "Compulsory" icon next to the "Invoice ID" field. Once activated, the icon will be highlighted in red.



3. Save your changes, and then publish and run the form.

4. You now find that you must now fill in the Invoice ID before you are allowed to save the form.



Duplicate data validation


1. Now let us say you need to make sure that you do not create duplicate records with the same Invoice ID. In other words, you need to apply duplicate data checking on the "Invoice ID" field.

2. To create duplicate data validation, click on the settings icon next to the "Invoice ID" field.

3. Change the "Allow duplicates" field from "Yes" to "No".



4. Save your changes, and then publish and run the form.

5. You now find that if you already have an existing Invoice ID keyed in, you cannot create and save another record with exactly the same Invoice ID.



Comments


bottom of page