a mini social media app for small communities
at main 1.0 kB view raw
1const add_password_checkers = (password_id, confirm_id, match_id) => { 2 const password = document.getElementById(password_id); 3 const confirm_password = document.getElementById(confirm_id); 4 const matches = document.getElementById(match_id); 5 6 const a = () => { 7 matches.innerText = password.value==confirm_password.value ? "yes" : "no"; 8 }; 9 password.addEventListener('input', a); 10 confirm_password.addEventListener('input', a); 11 12 const view_password = document.getElementById(`view-${password_id}`); 13 const view_confirm_password = document.getElementById(`view-${confirm_id}`); 14 15 const b = (elm, btn) => { 16 return _ => { 17 if (elm.getAttribute('type') == 'password') 18 { 19 elm.setAttribute('type', 'text'); 20 btn.value = 'hide'; 21 } 22 else 23 { 24 elm.setAttribute('type', 'password') 25 btn.value = 'show'; 26 } 27 }; 28 }; 29 view_password.addEventListener('click', b(password, view_password)); 30 view_confirm_password.addEventListener('click', b(confirm_password, view_confirm_password)); 31}