Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all input type password

Tags:

javascript

I'm new in javascript. I want to get all input type password on my html page.

I know that there is a way to do this kind off things using Javascript, but I don't know how.

Then, with each one, I want to assign an event on text changed.

How can I do this?

Thanks

like image 490
rpf Avatar asked Feb 19 '10 17:02

rpf


1 Answers

I presume you mean

<input type="password">

If so, you can try a function like this:

function getPwdInputs() {
  var ary = [];
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++) {
    if (inputs[i].type.toLowerCase() === "password") {
      ary.push(inputs[i]);
    }
  }
  return ary;
}
like image 70
Robusto Avatar answered Oct 23 '22 16:10

Robusto