0

I'm experimenting with Polymer elements and currently with the paper form elements.

I haven't still managed to find if it is possible to get in a Javascript variable the fact that a paper-form is valid. Any ideas?

I'm using auto-validate.

 <paper-input id="foo"
        name="foo"
        label="Foo"
        required
        auto-validate
        pattern="[A-Za-z0-9]+"
        error-message="Alphanumerical characters only">
 </paper-input>

Thanks a lot!

luthien
  • 1,285
  • 3
  • 15
  • 26

1 Answers1

2

There is a property on the paper-input element called invalid which you can check to see if the value of the input is valid or not.

For example:

<paper-input id="foo"
  name="foo"
  label="Foo"
  required
  auto-validate
  pattern="[A-Za-z0-9]+"
  invalid="{{invalid}}"
  error-message="Alphanumerical characters only">
</paper-input>

And then in the JavaScript you can call

var invalid = this.$.foo.invalid;

See the docs here for more info.

Ben Thomas
  • 3,180
  • 2
  • 20
  • 38