Guest User

Untitled

a guest
Jun 8th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <input type="password" name="password" id="password">
  2. <a href="#" class="showPass">Показать</a>
  3. <a href="#" class="genPass">Сегенерировать</a>
  4.  
  5.  
  6. <script>
  7. function pass_rand(){var result = '';var words = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';var max_position = words.length - 1;for( i = 0; i < 20; ++i ){position = Math.floor(Math.random() * max_position); result = result + words.substring(position, position + 1);} return result;}$('.showPass').click(function(e){e.preventDefault();var inputPsw = $('#password');if (inputPsw.attr('type') == 'password'){document.getElementById('password').setAttribute('type', 'text');}else {document.getElementById('password').setAttribute('type', 'password');}});$('.genPass').click(function(e){e.preventDefault();document.getElementById('password').setAttribute('type', 'text');$('#password').attr('value', pass_rand());});
  8. </script>
Add Comment
Please, Sign In to add comment