I am using Polymer for a short time and now i want to get the value of a paper input. I don't know how can I do this. This is not working:
this.form.password
I want to get the Value of this field:
<paper-input label="Password" type="password" id="password" name="password" size="25" value=""></paper-input>
I also want get the Input for submitting of the e-mail input:
<paper-input label="Login" id="email" name="email" size="25" value=""></paper-input>
For submitting I am using:
<paper-button raised value="Login" type="submit" onclick="formhash(this.form, this.form.password);">Login</paper-button>
With normal input fields is this working.
If you don't want to use
<form>
you can also simply store the paper-input values in instance variables and use them later wherever you want.All you have to do is store the input inside a value like this:
<paper-input label="Password" type="password" id="password" name="password" size="25" value="{{valueNameToStore}}"></paper-input>
And later access it like this:
var myPassword = this.valueNameToStore;
You can use
document.querySelector('#password').value
to get the value ofpaper-input
with idpassword
in theformhash()
function call or inside the function definition.You can also use polymer's Automatic node finding to get value of an element using its
id
. In which keep the form/input in custom-element and usethis.$.password.value
to get the value of an element with idpassword
. Like thisUsing
<form is="iron-form">
allows you to use<paper-input>
and other input elements in forms https://elements.polymer-project.org/elements/iron-form