【问题标题】:What is the best administrative level for autocompleting addesses in German cities在德国城市自动完成地址的最佳行政级别是什么
【发布时间】:2020-12-21 15:07:26
【问题描述】:

邮政地址的autofill 属性具有4 different "administrative levels"。该文档为美国、英国、中国和日本提供了一些示例。我想知道德国地址中的城市是否有一些规范(或所有国家如何构建其行政级别的表格)。对于德国,使用address-level1 和address-level2 都对城市有意义:

  • address-level1 因为通常我们不在地址中包含县(Bundesland),所以使用“最高”级别是有道理的,模仿英国地址的指定方式。
  • address-level2 因为如果你想非常具体,它是地址的第 2 级,第 1 级是县。

有任何官方参考资料或数据可以支持吗?

【问题讨论】:

    标签: html localization autofill


    【解决方案1】:

    我会说,address-level2 是德国地址所需要的。

    The specs say:

    第二个行政级别,在具有两个或多个行政级别的地址中; 在有两个行政级别的国家/地区,这通常是相关街道地址所在的城市、城镇、村庄或其他地方


    这是我使用的:

    <form>
      <input type="text" autocomplete="address-line1" placeholder="Straße und Hausnummer"/>
      <input type="text" autocomplete="postal-code" placeholder="PLZ"/>
      <input type="text" autocomplete="address-level2" placeholder="Stadt"/>
    </form>
    

    如果您想拆分街道名称和门牌号码,则需要使用解决方法:

    <form>
      <input type="text" autocomplete="address-line1" placeholder="Straße"/>
      <!-- "address-level4" is used as a workaround, because Chrome ignores `autocomplete="off"` -->
      <input type="text" autocomplete="address-level4" placeholder="Hausnummer"/>
      <input type="text" autocomplete="postal-code" placeholder="PLZ"/>
      <input type="text" autocomplete="address-level2" placeholder="Stadt"/>
    </form>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-13
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 2016-07-03
      • 2017-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多