Forms, fields and formulas

How do I validate the format of a phone number, postal code or special characters?

Add a Regex validation to the text field, use the built-in No special characters rule, or flag characters with find() in a formula.

How-to

Short answer: Add a Regex validation to the text field. For "letters and numbers only", use the built-in No special characters validation. Formulas can't use regex, so use find() there.

Why it happens

  • Regex works only as a field validation, not inside a formula.
  • Kissflow doesn't accept a regex wrapped in slashes, such as /^\d+$/.

How to fix it

To check a format with regex:

  1. Hover over the text field and click the Validation icon.
  2. Click +Add a validation rule and select Regex.
  3. Enter the pattern without surrounding slashes, for example:
    • US phone number: ^\d{3}-\d{3}-\d{4}$
    • Canadian postal code: ^[A-Z]\d[A-Z] \d[A-Z]\d$
  4. Click Customize error message and describe the format you expect.

See validating a text expression using regex for more patterns.

To block symbols, add the No special characters, Letters only or Numbers only validation. See field validations.

To flag special characters in another field:

  1. Add a text field and make it computed.
  2. Use IF(test_field.find("@") > 0 || test_field.find("#") > 0 || test_field.find("$") > 0, "N", ""), listing every character you want to catch.

For extraction that needs regex or loops, use a JavaScript on-change field event with kf.context.getField and kf.context.updateField. Field events need the Enterprise plan.

Related answers