<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12988</bug_id>
          
          <creation_ts>2011-06-18 13:33:56 +0000</creation_ts>
          <short_desc>I&apos;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</short_desc>
          <delta_ts>2011-08-04 05:06:44 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#text-state-and-search-state</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>axelwinter</cc>
    
    <cc>ayg</cc>
    
    <cc>jackalmage</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>49830</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-06-18 13:33:56 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#text-state-and-search-state
Complete: http://www.whatwg.org/c#text-state-and-search-state

Comment:
I&apos;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. I would suggest to add a type=zip to the
specifications.

Posted from: 178.198.193.207
User agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49836</commentid>
    <comment_count>1</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2011-06-18 16:47:29 +0000</bug_when>
    <thetext>Use &lt;input type=text pattern=&quot;\d{5}(-\d{4})?&quot;&gt;.

I&apos;ll close this bug as WORKSFORME - please reopen if you feel your problem isn&apos;t addressed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49838</commentid>
    <comment_count>2</comment_count>
    <who name="Axel">axelwinter</who>
    <bug_when>2011-06-18 17:16:40 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Use &lt;input type=text pattern=&quot;\d{5}(-\d{4})?&quot;&gt;.
&gt; 
&gt; I&apos;ll close this bug as WORKSFORME - please reopen if you feel your problem
&gt; isn&apos;t addressed.

The pattern attribute only works for type=text, but not for number. I a lot of countries the zip-code is just a number. Example in Switzerland it is a 4 digit number. The number must be in between 1000 and 9659. I think here it would be appropriate to use number, especially because on mobile devices the keyboard would change to a number-pad. Type=tel would work too, but is semantically incorrect.

With type=text there is no chance to check validity by browser and as far as I know, you cant address this with regex.

I know there are countries that have also letters in the zip-code, so numbers would not work. That&apos;s why I think a type=zip is needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49839</commentid>
    <comment_count>3</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2011-06-18 17:24:07 +0000</bug_when>
    <thetext>I&apos;m confused.  Did you read my response?  In it, I described exactly how to make an input that only accepts valid US zipcodes.  Is my suggestion inadequate in some way?

You also bring up the issue of international postal codes.  This is a substantially different problem, because there is *no* pattern to them.  If you&apos;re accepting international addresses, the postal code field needs to be a plain &lt;input type=text&gt;, with no additional constraints.  I type=zip wouldn&apos;t be able to help you at all here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49864</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-06-19 22:18:12 +0000</bug_when>
    <thetext>If the purpose is to address international zip codes, how would the input behave any differently from type=text?  If it behaves the same, why do we need a new one?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49906</commentid>
    <comment_count>5</comment_count>
    <who name="Axel">axelwinter</who>
    <bug_when>2011-06-20 09:07:15 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; If the purpose is to address international zip codes, how would the input
&gt; behave any differently from type=text?  If it behaves the same, why do we need
&gt; a new one?

(In reply to comment #3)
&gt; I&apos;m confused.  Did you read my response?  In it, I described exactly how to
&gt; make an input that only accepts valid US zipcodes.  Is my suggestion inadequate
&gt; in some way?
&gt; 
&gt; You also bring up the issue of international postal codes.  This is a
&gt; substantially different problem, because there is *no* pattern to them.  If
&gt; you&apos;re accepting international addresses, the postal code field needs to be a
&gt; plain &lt;input type=text&gt;, with no additional constraints.  I type=zip wouldn&apos;t
&gt; be able to help you at all here.

Sorry for taking so long to reply.

My problem is that there is no clean and semantic way to address international zip-codes, and validate them as needed.

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&apos;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.

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 &quot;force&quot; a number-pad.

At the moment the only type to use is as you say type=text, but that needs JavaScript to check validity in the upper cases.

I hope that clarifies my intentions to open this issue</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49927</commentid>
    <comment_count>6</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2011-06-20 17:35:39 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; My problem is that there is no clean and semantic way to address international
&gt; 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.
 
&gt; The example from Switzerland is that the zip-code must consist 4 numbers (easy
&gt; to check with regex), but also has to be in between 1000 and 9659. I&apos;m not sure
&gt; if that an be done with pattern. What I think is needed is a type that allows
&gt; the attributes pattern, min and max, that way we could address the Swiss
&gt; problem, and also check validity of, as an example Canadian postcodes
&gt; consisting letters and numbers.

&lt;input type=text pattern=&quot;([1-8]\d\d\d)|(9[0-5]\d\d)|(96[0-5]\d)&quot;&gt;

That pattern should properly limit you to a 4-digit number between 1000 and 9659.
 
&gt; In case of an numerical postcode, it would be nice if we can set the keyboard
&gt; to a number-pad making input easier for users on mobile devices. The same is if
&gt; you need a formfield for credit-card numbers, there is no type that gives the
&gt; possibility to &quot;force&quot; a number-pad.

This is being discussed elsewhere.  Look for the bug about type=numeric.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49941</commentid>
    <comment_count>7</comment_count>
    <who name="Axel">axelwinter</who>
    <bug_when>2011-06-20 20:11:44 +0000</bug_when>
    <thetext>Wow this is amazing... I did not know that this could be done with regular expressions.
Looks like I have to read up a bit on redex. Anyway this solves the &quot;Swiss problem&quot; and the type=numeric discussion you pointed out is exactly what I tried to explain too.

Anway Problem solved

THX 10 times</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53103</commentid>
    <comment_count>8</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:06:44 +0000</bug_when>
    <thetext>mass-moved component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>