Forum

Thread tagged as: Question, Forms

Form input patterns

Can perch form errors handle input patterns, for example:

<perch:input type="text" id="shipping_postcode" label="Postal code" class="form-control" title="Postcode must begin with CH or LL" pattern="^(CH|LL).*$">

If not, please consider this a feature request :)

Joseph Spurling

Joseph Spurling 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It does, yes. What problem are you seeing?

I'm also trying to use a pattern, it prevents the form submitting if the pattern isn't matched but it doesn't display my error. Is type="pattern" the correct attribute to use in the error?

<perch:input type="password" id="password" required="true" match-with="password2" class="form-control" pattern="^.{8,}$" />
<perch:error for="password" type="pattern">Please use the correct format</perch:error>

The attribute for the regex pattern error should be type="format"