index.html
4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<title>iron-form demo</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../paper-input/paper-input.html">
<link rel="import" href="../../paper-button/paper-button.html">
<link rel="import" href="../../paper-styles/paper-styles.html">
<link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="../../paper-checkbox/paper-checkbox.html">
<link rel="import" href="../iron-form.html">
<link rel="import" href="simple-element.html">
</head>
<style>
.wide {
width: 474px;
}
</style>
<body>
<div class="horizontal center-center layout">
<div>
<h4>method="get"</h4>
<div class="horizontal-section">
<form is="iron-form" id="formGet" method="get" action="/">
<paper-input name="name" label="Name" required></paper-input>
<paper-input name="animal" label="Favourite animal" required></paper-input>
<br>
<input type="checkbox" name="food" value="donuts" checked> I like donuts<br>
<input type="checkbox" name="food" value="pizza" required> I like pizza<br>
<paper-checkbox name="food" value="cheese" required>I like cheese</paper-checkbox><br>
<p>
Sample custom element, not required: <br>
<simple-element name="custom-one"></simple-element>
</p>
<p>
Sample custom element, required: (look, styling!)<br>
<simple-element required name="custom-two"></simple-element><br>
</p>
<br><br>
<paper-button raised
onclick="clickHandler(event)">Submit</paper-button>
</form>
</div>
</div>
<div>
<h4>method="post"</h4>
<div class="horizontal-section">
<form is="iron-form" id="formPost" method="post" action="/">
<paper-input name="name" label="Name" required></paper-input>
<br>
<p>Duplicate name <input name="name" required></p>
<input type="radio" name="color" value="red" checked>Red<br>
<input type="radio" name="color" value="blue" checked>Blue<br>
<input type="radio" name="color" value="green">Green<br>
<br>
<label>Cars</label>
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
<br><br>
<label>Browsers</label>
<input list="browsers" name="browsers" required>
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
<br><br>
<label>Pick a number</label>
<input type="range" name="number" min="1" max="100">
<br><br><br>
<paper-button raised
onclick="clickHandler(event)">Submit</paper-button>
<button type="submit">Native Submit</button>
</form>
</div>
</div>
</div>
<br><br>
<div class="layout vertical center-center">
<div>
<h4>Submitted form data</h4>
<div class="horizontal-section wide">
<div id="output"></div>
</div>
</div>
</div>
<script>
document.getElementById('formGet').addEventListener('iron-form-submit', display);
document.getElementById('formPost').addEventListener('iron-form-submit', display);
function display(event) {
var output = document.getElementById('output');
output.innerHTML = JSON.stringify(event.detail);
}
function clickHandler(event) {
Polymer.dom(event).localTarget.parentElement.submit();
}
</script>
</body>
</html>