[php] me

Viewer

  1. <?php 
  2. $var = 'var myInput = document.getElementById("psw");
  3. var letter = document.getElementById("letter");
  4. var capital = document.getElementById("capital");
  5. var number = document.getElementById("number");
  6. var length = document.getElementById("length");
  7.  
  8. // When the user clicks on the password field, show the message box
  9. myInput.onfocus = function() {
  10.   document.getElementById("message").style.display = "block";
  11. }
  12.  
  13. // When the user clicks outside of the password field, hide the message box
  14. myInput.onblur = function() {
  15.   document.getElementById("message").style.display = "none";
  16. }
  17.  
  18. // When the user starts to type something inside the password field
  19. myInput.onkeyup = function() {
  20.   // Validate lowercase letters
  21.   var lowerCaseLetters = /[a-z]/g;
  22.   if(myInput.value.match(lowerCaseLetters)) {
  23.     letter.classList.remove("invalid");
  24.     letter.classList.add("valid");
  25.   } else {
  26.     letter.classList.remove("valid");
  27.     letter.classList.add("invalid");
  28. }
  29.  
  30.   // Validate capital letters
  31.   var upperCaseLetters = /[A-Z]/g;
  32.   if(myInput.value.match(upperCaseLetters)) {
  33.     capital.classList.remove("invalid");
  34.     capital.classList.add("valid");
  35.   } else {
  36.     capital.classList.remove("valid");
  37.     capital.classList.add("invalid");
  38.   }
  39.  
  40.   // Validate numbers
  41.   var numbers = /[0-9]/g;
  42.   if(myInput.value.match(numbers)) {
  43.     number.classList.remove("invalid");
  44.     number.classList.add("valid");
  45.   } else {
  46.     number.classList.remove("valid");
  47.     number.classList.add("invalid");
  48.   }
  49.  
  50.   // Validate length
  51.   if(myInput.value.length >= 8) {
  52.     length.classList.remove("invalid");
  53.     length.classList.add("valid");
  54.   } else {
  55.     length.classList.remove("valid");
  56.     length.classList.add("invalid");
  57.   }
  58. }';

Editor

You can edit this paste and save as new: