# Formats and maximum lengths - Fieldline 1.x documentation

> Make the answer to a text field match a format, such as a VAT number, with your own message, and limit its length.

> [!NOTE]
> This is part of **Fieldline Pro**.

Text and text area fields can check the shape of an answer before the order is placed: a VAT number that looks like one, a membership number with the right prefix, a gift message that fits on the card.

![The Format and Maximum length settings](https://storage.extendiment.com/media/964/screenshot-4-204c5523.png)

## Format

Edit a text or text area field and fill in **Format** with a regular expression the whole answer must match, the same as an HTML `pattern` attribute. Then write the **Message when it doesn't match**, which customers see when it doesn't.

| You want | Format | Message |
|---|---|---|
| A UK VAT number | `GB[0-9]{9}` | Enter a VAT number such as GB123456789. |
| Any EU VAT number | `[A-Z]{2}[0-9A-Z]{2,12}` | Enter your VAT number with its country code, such as DE123456789. |
| A membership number | `NW-[0-9]{5}` | Membership numbers look like NW-12345. |
| A US ZIP code | `[0-9]{5}(-[0-9]{4})?` | Enter a 5-digit ZIP code. |
| Letters and spaces only | `[A-Za-z ]+` | Use letters only. |

- The format is matched against the **whole** answer, so `[0-9]{5}` means exactly five digits, not "contains five digits".
- Upper and lower case are different: `[A-Z]` only matches capitals. Write `[A-Za-z]` for both.
- An empty answer is never checked against the format. Tick **Required** too if the field must be filled in.
- Without a message of your own, customers see "VAT number is not in the right format."

If the format isn't a valid regular expression, the field isn't saved and you're asked to correct it.

## Maximum length

Fill in **Maximum length** with a number of characters, for example 120 for a gift card message. The customer can't type more than that, and a longer answer is refused with "Gift card message can be at most 120 characters." Leave it empty for no limit.

Characters are counted as customers see them, so an accented letter such as "é" counts as one.

## How it's checked

- In the browser, as the customer types: both checkouts get the format and the length, so the browser points out a wrong answer before the customer clicks **Place order**.
- On the server, when the order is placed: every answer is checked again, so a browser that ignores the format can't get a wrong answer through.

Formats and maximum lengths apply to **text** and **text area** fields. Date, number, email and phone fields have their own check; see **More field types**.

Source: https://extendiment.com/plugins/fieldline/docs/1.x/formats-and-maximum-lengths
