•••
 
Documentation   /   Reference: syntax   /   String formats
 
 

String formats

 

---string_format checks a value before it's accepted. It works on text input actions, hooks, template fields and values sent to /hook. If the value doesn't match, the user sees an error and can try again.

Format Accepts Error shown
number (or integer) A whole number This should be a number.
float (or decimal) A decimal number This should be a decimal.
percentage A percentage, such as 12.5% This should be a percentage.
currency An amount with or without a currency symbol, such as £1,000 This should be a currency, e.g. £1000.
email (or email_address) An email address This should be an email.
phone (or phone_number) A phone number Phone number not recognised.
url (or link) A URL beginning https:// or http:// Your URL should begin with https:// or http://.
plainly_document The URL of a Plainly document This should be the URL of a Plainly document.
equals={text} Exactly that text Wrong format.
not_equals={text} Anything except that text Wrong format.
contains={text} (or match=) Text containing that text Wrong format.
not_contains={text} (or not_match=) Text not containing that text Wrong format.
regex={pattern} Text matching the regular expression Wrong format.

For equals, not_equals, contains and not_contains, add your own error message after a pipe:

---string_format:equals=I agree|Please type "I agree" to continue

Examples:

---string_format:currency
---string_format:email
---string_format:regex=^[A-Z]{2}[0-9]{6}[A-D]$
Note

An unrecognised format accepts any value. Check the spelling of the format name.