1+ <!--
2+ @license
3+ Copyright (c) 2015 David Howell. All rights reserved.
4+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5+ -->
6+ < link rel ="import " href ="../polymer/polymer.html ">
7+ < link rel ="import " href ="../paper-input/paper-input-behavior.html ">
8+ < link rel ="import " href ="../paper-input/paper-input-container.html ">
9+ < link rel ="import " href ="../paper-input/paper-input-error.html ">
10+ < link rel ="import " href ="../iron-input/iron-input.html ">
11+ < link rel ="import " href ="../iron-form-element-behavior/iron-form-element-behavior.html ">
12+ < link rel ="import " href ="postcode-validator.html ">
13+
14+ <!--
15+ `gold-postcode-input` is a single-line text field with Material Design styling
16+ for entering an Australian postcode.
17+
18+ <gold-postcode-input></gold-postcode-input>
19+
20+ It may include an optional label, which by default is "Postcode".
21+
22+ <gold-postcode-input label="Mailing postcode"></gold-postcode-input>
23+
24+ ### Validation
25+
26+ The input supports Australian 4-digit numeric postal codes with the following state based specific ranges.
27+ ACT: 0200-0299 and 2600-2639. NSW: 1000-1999, 2000-2599 and 2640-2914. NT: 0900-0999 and 0800-0899.
28+ QLD: 9000-9999 and 4000-4999. SA: 5000-5999. TAS: 7800-7999 and 7000-7499. VIC: 8000-8999 and 3000-3999.
29+ WA: 6800-6999 and 6000-6799.
30+
31+ The input can be automatically validated as the user is typing by using
32+ the `auto-validate` and `required` attributes. For manual validation, the
33+ element also has a `validate()` method, which returns the validity of the
34+ input as well sets any appropriate error messages and styles.
35+
36+ See `Polymer.PaperInputBehavior` for more API docs.
37+
38+ ### Styling
39+
40+ See `Polymer.PaperInputContainer` for a list of custom properties used to
41+ style this element.
42+
43+ @group Gold Elements
44+ @hero hero.svg
45+ @demo demo/index.html
46+ @class gold-postcode-input
47+ -->
48+
49+ < dom-module id ="gold-postcode-input ">
50+ < style >
51+ : host {
52+ dis play: block;
53+ }
54+ </ style >
55+
56+ < template >
57+
58+ < paper-input-container id ="container "
59+ auto-validate ="[[autoValidate]] "
60+ attr-for-value ="bind-value ">
61+
62+ < label hidden$ ="[[!label]] "> [[label]]</ label >
63+
64+ < postcode-validator > </ postcode-validator >
65+
66+ < input is ="iron-input " id ="input "
67+ aria-labelledby$ ="[[_ariaLabelledBy]] "
68+ aria-describedby$ ="[[_ariaDescribedBy]] "
69+ required$ ="[[required]] "
70+ validator ="postcode-validator "
71+ type ="tel "
72+ maxlength ="10 "
73+ bind-value ="{{value}} "
74+ autocomplete ="postal-code "
75+ name$ ="[[name]] ">
76+
77+ < template is ="dom-if " if ="[[errorMessage]] ">
78+ < paper-input-error id ="error "> [[errorMessage]]</ paper-input-error >
79+ </ template >
80+
81+ </ paper-input-container >
82+ </ template >
83+
84+ </ dom-module >
85+
86+ < script >
87+ ( function ( ) {
88+ Polymer ( {
89+
90+ is : 'gold-postcode-input' ,
91+
92+ behaviors : [
93+ Polymer . PaperInputBehavior ,
94+ Polymer . IronFormElementBehavior
95+ ] ,
96+
97+ properties : {
98+ /**
99+ * The label for this input.
100+ */
101+ label : {
102+ type : String ,
103+ value : "Postcode"
104+ }
105+ }
106+
107+ } )
108+
109+ } ) ( ) ;
110+
111+ </ script >
0 commit comments