Craft field type for text fields that match a regex pattern.
To install Match Input, follow these steps:
- Install with Composer via
composer require marionnewlevant/match-input
from your project directory - Install plugin in the Craft Control Panel under Settings > Plugins
or
- Install via the Plugin Store
Match Input works on Craft 3.x.
A Match Input field is a Plain Text field with the addition of a regex pattern that the field must match to be valid.
When you create the field, you specify the Input Mask
.
This is the PCRE Pattern which the
input is required to match.
You also specify an Error Message
to display when the field does not match the
pattern.
If you need to translate the Error Message
(for a multi-language control panel), those translations
will be in the site
translation category.
https://
- not a valid pattern (no delimiters)/https:\/\//
- valid pattern, will match string withhttps://
in it anywhere#https://#
- valid pattern, will match string withhttps://
in it anywhere (sometimes / isn't the best delimiter)#^https://#
- will match string that begins withhttps://
/^\d{5}(-\d{4})?$/
- will match 5 digits, optionally followed by-
and 4 digits (uses ^ and $ to match the entire string)
Brought to you by Marion Newlevant. Icon interior by SlideGenius from the Noun Project