I would like to create a registration form with hide-able and revealable password input. I tried this (JS):
function showhide(melyik,hol) {
var melyiket = document.getElementById(melyik);
var melyikkel = document.getElementById(hol);
if (melyikkel.value == '1') {
document.getElementById(melyikkel).value='0';
document.getElementById(melyiket).type='password';
} else {
document.getElementById(melyikkel).value='1';
document.getElementById(melyiket).type='text';
}
}
Form:
<div style="margin-top:20px;">
<p>SQL host: <input type="text" name="sql_host" value="localhost"/></p>
<p>SQL adatbázis: <input type="text" name="sql_db"/></p>
<p>SQL felhasználó: <input type="text" name="sql_user"/></p>
<p>SQL jelszó: <input type="text" name="sql_password" id="sql_password"/>
<input type="checkbox" name="show_password_1" id="show_password_1" value="0" onclick="showhide('sql_password','show_password_1');">
</p>
</div>
I want to do this: If checkbox is checked the password input type is text. When not checked the password type is password... I wrote this JavaScript, but not working. :-(