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