Hi everyone. It would be nice to have a pattern attribute on the postal code field, which will be used for client side validation. I will also supply a patch which uses the Address's formatting service.

Best Regards.

Comments

etroid’s picture

I second this request. Tried out the patch as provided in #1 and it works as expected.

s.messaris’s picture

Status: Needs review » Reviewed & tested by the community

I tested the patch on #1, works well. Changing to RTBC.

bojanz’s picture

Status: Reviewed & tested by the community » Needs work

Sure, why not.

We need to fix the code comment though:

+    // Add country specific postal code validation pattern as a pattern attribute
+    // to the textfield, which is needed for client side validation.

First line goes over the limit.

bojanz’s picture

Title: Postal code field pattern attribute. » Add a pattern attribute to the postal code field
Assigned: marios anagnostopoulos » Unassigned

bojanz’s picture

Status: Needs work » Fixed

Tweaked and committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bojanz’s picture

Title: Add a pattern attribute to the postal code field » [Reverted] Add a pattern attribute to the postal code field

I had to revert this: https://git.drupalcode.org/project/address/commit/8c66004

The addressing library explicitly performs case insensitive matching, just like Google's original code.
However, HTML5 only supports case sensitive matching. That means that it's more strict than the underlying PHP code.

This prompted the following bug report: #3051665: Postal Code validation should not be case sensitive.