Conditional execution

Overview

Conditional execution determine whether different components should execute or not.

Fortified ID's products use Javascript for this. There are four different parts of the products that use this. This document contains various examples for common tasks. How to address data that you might want to use is described in one of the four sub-documents and depends on what you are going to do.

Common syntax examples

When validating data with JavaScript, the goal is to ensure that the information entered by a user or provided to your application meets certain rules before it’s processed.

Required fields

  • Username is required (!username)

  • Next

Data type checks

  • Age must be a number isNaN(age))

  • Next

Length checks

  • Password must be at least 8 characters long password.length > 8

  • Next

Pattern checks with Regular Expressions (Regex)

Useful for formats like email or phone numbers.

  • Invalid email address emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; (!emailPattern.test(email))

  • Next

Range checks

  • Age must be between 18 and 100 age < 18 || age > 100

  • Next

Last updated