Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. document.addEventListener("DOMContentLoaded", function(event) {
  2.  
  3. var pass = document.getElementById("passwordInput")
  4. pass.addEventListener('keyup', function () {
  5. checkPassword(pass.value)
  6. })
  7. function checkPassword(password) {
  8. var strengthBar = document.getElementById("strength")
  9. var strength = 0;
  10. if (password.match(/[a-zA-Z0-9][a-zA-Z0-9]+/)) {
  11. strength += 1
  12. }
  13. if (password.match(/[~<>?]+/)) {
  14. strength += 1
  15. }
  16. if (password.match(/[!@£$%^*()]+/)) {
  17. strength += 1
  18. }
  19. if (password.length > 5) {
  20. strength += 1
  21. }
  22. switch (strength) {
  23. case 0:
  24. strengthBar.value = 20;
  25. break;
  26. case 1:
  27. strengthBar.value = 40;
  28. break;
  29. case 2:
  30. strengthBar.value = 60;
  31. break;
  32. case 3:
  33. strengthBar.value = 80;
  34. break;
  35. case 4:
  36. strengthBar.value = 100;
  37. break;
  38. }
  39.  
  40. }
  41. //do work
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement