Validate polymer input on data observation -


i'm trying make dynamic validation on polymer app want make #login-buttonbutton attribute disabled when inputs empty , remove attribute when imputs filled id , password. tried make html5 required attribute solution doesn't work. created button-click function hit api , want add validate function.

 <form id="form_login">             <paper-input  aria-required="true"  name="name" floatinglabel label="id*"                          value="{{name}}"></paper-input>             <br>             <paper-input-decorator floatinglabel label="password">                 <input aria-required="true" id="password" is="core-input" name="password" type="password"                        value="{{password}}"/>             </paper-input-decorator>             <br>               <div class="page-holder" horizontal layout center center-justified>              </div>              <div class="page-holder" horizontal layout center center-justified>                 <paper-button  id="login-button" on-click="{{buttonclick}}">zaloguj się</paper-button>             </div>         </form> 

my script:

    polymer('login-page',{         buttonclick: function () {                 this.$.ajaxsubmit.go();         },         responsechanged: function (oldvalue) {             console.log(this.response);             document.queryselector('app-router').go('/profile?hash=dfsasdsf');          }     }); </script> 

disabled?={{!name || !password}} of paper-button may check empty values in case. here how it:

<link rel="import" href="http://www.polymer-project.org/0.5/components/polymer/polymer.html">  <link rel="import" href="http://www.polymer-project.org/0.5/components/paper-elements/paper-elements.html">  <link rel="import" href="http://www.polymer-project.org/0.5/components/core-elements/core-elements.html">    <body fullbleed layout vertical>    <form-elem></form-elem>  </body>  <polymer-element name="form-elem" noscript>    <template>      <paper-input aria-required="true" floatinglabel label="id*" value="{{name}}"></paper-input>      <br>      <paper-input-decorator floatinglabel label="password">        <input aria-required="true" id="password" is="core-input" type="password" value="{{password}}" />      </paper-input-decorator>      <br>      <div class="page-holder" horizontal layout center center-justified></div>      <div class="page-holder" horizontal layout center center-justified>        <paper-button disabled?="{{!name || !password}}" id="login-button" on-click="{{buttonclick}}">zaloguj się</paper-button>      </div>    </template>  </polymer-element>

here jsfiddle version if needed: jsfiddle


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -