FAQ Q371: Can Planyo verify that a form field value entered by customer is correct?

Seksjon: Reservation form
Yes, the most basic verification would be to make a field required. You can do this by selecting the checkbox required field in the field's options in reservation form layout.

If you want to do a more complex verification, you'll need to add a pricing manager rule (here) of type reservation form item. You'll need to select the text field you want to verify and then the option value should be set to make sure any invalid value cannot be accepted on the reservation form.

There are several possibilities of what you can enter as value:
With such configuration, when a customer enters a value which matches the pricing manager rule, the price calculated so far can be altered - but in this scenario we want to display an error message instead of setting a price. In order to do this, you'll need to choose: unavailability message instead of the price unit (such as EUR per day or EUR) and type the error text in place of the price. Also, if you want the error to be printed if there is NO match (e.g. if the entered text does NOT have given prefix) then you'll need to add another rule of type always true whose advanced condition will say apply this rule only if none of the rules were applied and select your reservation form item rule.

Advanced regex pattern matching

Regular expressions (regex) allow you to perform an advanced verification of the entered value. You can use it e.g. to make sure the entered value has a correct license plate format, or simply to make sure the entered value is a text between X and Y characters (or upper-case letters or alphanumeric characters etc.). Almost any types of rules can be created using regex pattern matching, you will find many resources on the Internet (e.g. here or here) which will help you to generate the correct regex pattern.

Regex-based pattern can be entered as a rule value by using the regex: or noregex: prefix. Below are some examples you can use:
regex:/^[A-Z0-9]{4,6}$/ will cause the rule to be used when the value is composed of 4 to 6 alphanumeric characters
noregex:/^[A-Z0-9]{4,6}$/ will cause the rule to be used when the value doesn't match this pattern - this allows you to directly enter an unavailability message in the same rule instead of adding the always true rule with the condition.
noregex:/^[A-Z.]+$/i will display your error message if the value includes any characters other than letters (lower- or upper-case will be accepted) or a dot/period
noregex:/^[0-9]{4,6}$/ will display your error message if the value is not a number or if it's a number having less than 4 or more than 6 digits
noregex:/^ABC[0-9]{4}$/ will display your error message if the value doesn't match the following format: a four-digit number prefixed with ABC, e.g. ABC0001 or ABC6789
noregex:/^(ABC|DEF)[0-9]{4}$/ same as above but also allows for the DEF prefix, e.g. ABC0001 or DEF6789
noregex:/^https?://[^s/$.?#].[^s]*$/ will show an error message if the value is not a URL
noregex:/^[A-Za-z0-9._%+-]+@[A-Za-z0–9.-]+.[A-Z|a-z]{2,}$/ will show an error message if the value is not an email address
noregex:/^d{4}-d{1,2}-d{1,2}$/ will show an error message if the value is not a date in the format YYYY-MM-DD

Note that if the value of a field is empty and when using the noregex syntax, the regular expression pattern will be ignored and the rule will not be applied (and so the error message will not be displayed for the empty value). Please see the note about the required field option at the top of this page if you wish to force the customer to enter a value into a field.

Ofte spurte spørsmål