README.md
1
2 <!---
3
4 This README is automatically generated from the comments in these files:
5 iron-validatable-behavior.html
6
7 Edit those files, and our readme bot will duplicate them over here!
8 Edit this file, and the bot will squash your changes :)
9
10 The bot does some handling of markdown. Please file a bug if it does the wrong
11 thing! https://github.com/PolymerLabs/tedium/issues
12
13 -->
14
15 [![Build status](https://travis-ci.org/PolymerElements/iron-validatable-behavior.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-validatable-behavior)
16
17 _[Demo and API docs](https://elements.polymer-project.org/elements/iron-validatable-behavior)_
18
19
20 ##Polymer.IronValidatableBehavior
21
22 `Use Polymer.IronValidatableBehavior` to implement an element that validates user input.
23 Use the related `Polymer.IronValidatorBehavior` to add custom validation logic to an iron-input.
24
25 By default, an `<iron-form>` element validates its fields when the user presses the submit button.
26 To validate a form imperatively, call the form's `validate()` method, which in turn will
27 call `validate()` on all its children. By using `Polymer.IronValidatableBehavior`, your
28 custom element will get a public `validate()`, which
29 will return the validity of the element, and a corresponding `invalid` attribute,
30 which can be used for styling.
31
32 To implement the custom validation logic of your element, you must override
33 the protected `_getValidity()` method of this behaviour, rather than `validate()`.
34 See [this](https://github.com/PolymerElements/iron-form/blob/master/demo/simple-element.html)
35 for an example.
36
37 ### Accessibility
38
39 Changing the `invalid` property, either manually or by calling `validate()` will update the
40 `aria-invalid` attribute.
41
42
43