[Bug 12988] I'm a bit in trouble on what type to apply for zip- postcodes. I would use type=number, but then I cant use the maxlenght attribute. While using type=text there are no max min attributes. No matter what type I choose, none of them works for zip- postcodes

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12988

--- Comment #6 from Tab Atkins Jr. <jackalmage@gmail.com> 2011-06-20 17:35:39 UTC ---
(In reply to comment #5)
> My problem is that there is no clean and semantic way to address international
> zip-codes, and validate them as needed.

There is no way to automatically validate international postal codes, because
the per-country limitations are all over the board (as you note, Switzerland
has a somewhat arbitrary range from 1000-9659).  If there is a specific country
you need to validate, you can probably do it with @pattern.

> The example from Switzerland is that the zip-code must consist 4 numbers (easy
> to check with regex), but also has to be in between 1000 and 9659. I'm not sure
> if that an be done with pattern. What I think is needed is a type that allows
> the attributes pattern, min and max, that way we could address the Swiss
> problem, and also check validity of, as an example Canadian postcodes
> consisting letters and numbers.

<input type=text pattern="([1-8]\d\d\d)|(9[0-5]\d\d)|(96[0-5]\d)">

That pattern should properly limit you to a 4-digit number between 1000 and
9659.

> In case of an numerical postcode, it would be nice if we can set the keyboard
> to a number-pad making input easier for users on mobile devices. The same is if
> you need a formfield for credit-card numbers, there is no type that gives the
> possibility to "force" a number-pad.

This is being discussed elsewhere.  Look for the bug about type=numeric.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Monday, 20 June 2011 17:35:42 UTC