# US Social Security Number (SSN)

## Availability

[\[SINCE Orbeon Forms 2024.1.2\]](https://doc.orbeon.com/release-notes/orbeon-forms-2024.1.2)

## What it does

This component represents a US Social Security Number (SSN).

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-4c6b65f35553c7210e480ad8428c05e81182467c%2Fxbl-us-ssn-edit-obscured.webp?alt=media" alt="" width="220"><figcaption><p>US Social Security Number (SSN) field with obscured value</p></figcaption></figure>

It allows the user to enter a Social Security Number in the format `078-05-1120`, with or without the dashes.

* The user input is sanitized to remove any non-digit characters.
* The user input is validated:
  * to ensure that it contains exactly 9 digits, otherwise the field value is considered invalid
  * and to reject known invalid patterns, such as numbers starting with `000`, `666`, or `9`, or numbers that are all the same digit (e.g., `111-11-1111`)
* The value is formatted as `078-05-1120` when displaying the value.
* The value is stored in the database as a string of 9 digits including two separator dashes, for example `078-05-1120`.

*NOTE: Storing the value with dashes is a design choice which seems to match the most common usage.*

## Options

Because a Social Security Number is a sensitive piece of information, by default the value of the field is not shown entirely:

* In editable modes, the value is obscured, like a password field.
* In readonly modes, such as the View and PDF modes, only the last four digits are shown, like `•••-••-1120`.

For editable modes, you can configure the field to behave in the following ways:

| Mode             | Description                                                                                                                                                                 | Example                      |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| Always visible   | Field is always shown in plain text                                                                                                                                         | `078-05-1120`                |
| Always obscured  | Field is always hidden                                                                                                                                                      | `•••••••••`                  |
| Reveal on demand | Field is hidden by default, but can be revealed when the user clicks a "Reveal" checkbox. Useful for verifying the value while keeping it hidden from onlookers by default. | `078-05-1120` or `•••••••••` |

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-325f510c9e6c694ff157ad8a2b052a205c9c1061%2Fxbl-us-ssn-edit-revealed.webp?alt=media" alt="" width="220"><figcaption><p>US Social Security Number (SSN) field with revealed value</p></figcaption></figure>

For readonly modes, such as the View and PDF modes, you can configure the field to behave in the following ways:

| Mode                  | Description                           | Example       |
| --------------------- | ------------------------------------- | ------------- |
| Visible               | Field is fully shown in plain text    | `078-05-1120` |
| Obscured              | Field is fully hidden                 | `•••-••-••••` |
| Show last four digits | Only the last four digits are visible | `•••-••-1120` |

<figure><img src="https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-1b97804af28f497fa0f2f95b718eb40b6c84d01e%2Fxbl-us-ssn-view-partial.webp?alt=media" alt="" width="440"><figcaption><p>US Social Security Number (SSN) field with partially-revealed value</p></figcaption></figure>

These options are controlled in Form Builder or using configuration properties:

* at the form control level, using the "Control Settings" dialog
* at the form level, using the "Form Settings" dialog
* in configuration properties

![US Social Security Number (SSN) field settings](https://4129616727-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LEkBiSDvlXs3VWiO0Zu%2Fuploads%2Fgit-blob-7a4a7815a5674722a9eafbdabfb090263afe6704%2Fxbl-us-ssn-settings.webp?alt=media)

The default properties are as follows:

```xml
<property as="xs:string"  name="oxf.xforms.xbl.fr.us-ssn.edit-format"                        value="reveal"/> <!-- allowed values: `obscured`, `visible`, `reveal` -->
<property as="xs:string"  name="oxf.xforms.xbl.fr.us-ssn.view-format"                        value="partial"/><!-- allowed values: `obscured`, `visible`, `partial` -->
<property as="xs:string"  name="oxf.xforms.xbl.fr.us-ssn.pdf-format"                         value="partial"/><!-- allowed values: `obscured`, `visible`, `partial` -->
<property as="xs:string"  name="oxf.xforms.xbl.fr.us-ssn.pdf-template-format"                value="partial"/><!-- allowed values: `obscured`, `visible`, `partial` -->
```

## Data security and GDPR

Because the SSN is a sensitive piece of information, we recommend that you handle this data in the following ways:

* First, consider not requesting this information from users unless absolutely necessary.
* Second, if you request it, consider making only transient use of it, such as calling a verification service, without storing it in your database.
* Finally, if you do store it, consider encrypting it in your database, and ensure that you comply with data protection regulations such as GDPR. Orbeon Forms [supports encryption at rest](https://doc.orbeon.com/form-builder/advanced/field-level-encryption), which satisfies this requirement.

## See also

* Blog post: [Field-level encryption](https://blog.orbeon.com/2019/04/field-level-encryption.html)
* [Field-level encryption](https://doc.orbeon.com/form-builder/advanced/field-level-encryption)
* [Basic Settings](https://doc.orbeon.com/form-builder/form-editor/control-settings)
* [US Employer Identification Number (EIN)](https://doc.orbeon.com/form-runner/component/us-ein)
* [US Phone Number](https://doc.orbeon.com/form-runner/component/us-phone)
* [US State](https://doc.orbeon.com/form-runner/component/us-state)
