plain-solutions-gmbh / kirby-form-block-suite

This form plugin for Kirby offers you maximum flexibility and usability. It can be used as a block anywhere you needed. This repository replaces the obsolete version 2.0.
Other
38 stars 11 forks source link

Question: format of regular expressions for validation? #52

Closed brandsis closed 3 months ago

brandsis commented 3 months ago

Hi, Roman. I'm adding a postal code field to a client's form and I need to restrict the input using a regular expression. But I can't figure out the correct way to enter it into the validation section of the field.

The format needs to be a UK postcode starting with "HP22 5" or "HP22 6" and followed by two more alpha characters. The pattern I've successfully used before is [Hh][Pp][2][2]? [5-6]{1}[A-Za-z]{2}.

If I put that into a regex tester and try different variations, the results are as intended...

image

However, if I add that expression into the Panel field as is, there is no validation in the front-end and any input is allowed. I've tried enclosing the expression in ' ' and starting/ending it with /, and combinations of those, but then no input is considered valid.

How should I enter the expression in the Panel so that only postcodes starting with "HP22 5" or "HP22 6" are allowed?

plain-solutions-gmbh commented 3 months ago

Please Check this...

brandsis commented 3 months ago

Thanks. Got it working.