How to Validate US Social Security Number Field in Shack Forms

In some cases, you may want to ensure that users enter a valid US Social Security Number (SSN) in your Shack Forms Pro module.

The correct format for a US SSN is NNN-NN-NNNN, where each "N" represents a digit. To enforce this specific format, you can use a regular expression (RegEx) in your form field settings.

Follow these steps to add SSN validation to your Shack Forms field:

  • Open the Shack Forms Pro module where you want to add SSN validation.
  • Edit the field intended to collect the Social Security Number.
  • Set the Field type to Text.
  • In the Validation (Regular Expression) field, enter the following RegEx: /^\d{3}-\d{2}-\d{4}$/:

US Social Security Number validation code

  • This expression ensures that the user input follows the required SSN format: three digits, followed by a dash, then two digits, another dash, and finally four digits.
  • Click Save or Save & Close to apply your changes.

Now, your Shack Forms field will only accept input that matches the standard US Social Security Number format.