title: Copy password2 field automatically from password field in html
body: <p>I want to make my sign up form simples.
  I want to hide the password2 field and copy the value entered in password field automatically to password2 field. I tried a javascript but it did not work.
  This is what i tried.</p>
  <pre><code>&lt;td&gt;&lt;span class=&quot;smalltext&quot;&gt;{$lang-&gt;password}&lt;/span&gt;&lt;/td&gt;
  &lt;td&gt;&lt;span class=&quot;smalltext&quot;&gt;{$lang-&gt;confirm_password}&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type=&quot;password&quot; class=&quot;textbox&quot; name=&quot;password&quot; id=&quot;password&quot; style=&quot;width: 100%&quot; /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type=&quot;password&quot; class=&quot;textbox&quot; name=&quot;password2&quot; id=&quot;password2&quot; style=&quot;width: 100%&quot; /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
      &lt;td colspan=&quot;2&quot; style=&quot;display: none;&quot; id=&quot;password_status&quot;&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;script&gt;
  $(function(){
      var $foo = $('#password');
      var $bar = $('#password2');
      function onChange() {
          $bar.val($foo.val());
      };
      $('#password')
          .change(onChange)
          .keyup(onChange);
  });
  &lt;/script&gt;
  </code></pre>