OLD | NEW |
1 <!-- | 1 <!-- |
2 @license | 2 @license |
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. | 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
7 Code distributed by Google as part of the polymer project is also | 7 Code distributed by Google as part of the polymer project is also |
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
9 --> | 9 --> |
10 | 10 |
11 <link rel="import" href="../polymer/polymer.html"> | 11 <link rel="import" href="../polymer/polymer.html"> |
12 <link rel="import" href="../iron-meta/iron-meta.html"> | 12 <link rel="import" href="../iron-meta/iron-meta.html"> |
13 | 13 |
14 <script> | 14 <script> |
15 | 15 |
16 /** | 16 /** |
17 * Use `Polymer.IronValidatableBehavior` to implement an element that validate
s user input. | 17 * `Use Polymer.IronValidatableBehavior` to implement an element that validate
s user input. |
| 18 * Use the related `Polymer.IronValidatorBehavior` to add custom validation lo
gic to an iron-input. |
| 19 * |
| 20 * By default, an `<iron-form>` element validates its fields when the user pre
sses the submit button. |
| 21 * To validate a form imperatively, call the form's `validate()` method, which
in turn will |
| 22 * call `validate()` on all its children. By using `Polymer.IronValidatableBeh
avior`, your |
| 23 * custom element will get a public `validate()`, which |
| 24 * will return the validity of the element, and a corresponding `invalid` attr
ibute, |
| 25 * which can be used for styling. |
| 26 * |
| 27 * To implement the custom validation logic of your element, you must override |
| 28 * the protected `_getValidity()` method of this behaviour, rather than `valid
ate()`. |
| 29 * See [this](https://github.com/PolymerElements/iron-form/blob/master/demo/si
mple-element.html) |
| 30 * for an example. |
18 * | 31 * |
19 * ### Accessibility | 32 * ### Accessibility |
20 * | 33 * |
21 * Changing the `invalid` property, either manually or by calling `validate()`
will update the | 34 * Changing the `invalid` property, either manually or by calling `validate()`
will update the |
22 * `aria-invalid` attribute. | 35 * `aria-invalid` attribute. |
23 * | 36 * |
24 * @demo demo/index.html | 37 * @demo demo/index.html |
25 * @polymerBehavior | 38 * @polymerBehavior |
26 */ | 39 */ |
27 Polymer.IronValidatableBehavior = { | 40 Polymer.IronValidatableBehavior = { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 125 |
113 _getValidity: function(value) { | 126 _getValidity: function(value) { |
114 if (this.hasValidator()) { | 127 if (this.hasValidator()) { |
115 return this._validator.validate(value); | 128 return this._validator.validate(value); |
116 } | 129 } |
117 return true; | 130 return true; |
118 } | 131 } |
119 }; | 132 }; |
120 | 133 |
121 </script> | 134 </script> |
OLD | NEW |