Advertisement
Punisher1542

Login Code

May 11th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Login Page</title>
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <style>
  7. /* Style all input fields */
  8. input {
  9. width: 100%;
  10. padding: 12px;
  11. border: 1px solid #ccc;
  12. border-radius: 4px;
  13. box-sizing: border-box;
  14. margin-top: 6px;
  15. margin-bottom: 16px;
  16. }
  17.  
  18. /* Style the submit button */
  19. input[type=submit] {
  20. background-color: #4CAF50;
  21. color: white;
  22. }
  23.  
  24. /* Style the container for inputs */
  25. .container {
  26. background-color: #f1f1f1;
  27. padding: 20px;
  28. }
  29.  
  30. /* The message box is shown when the user clicks on the password field */
  31. #message {
  32. display:none;
  33. background: #f1f1f1;
  34. color: #000;
  35. position: relative;
  36. padding: 20px;
  37. margin-top: 10px;
  38. }
  39.  
  40. #message p {
  41. padding: 10px 35px;
  42. font-size: 18px;
  43. }
  44.  
  45. /* Add a green text color and a checkmark when the requirements are right */
  46. .valid {
  47. color: green;
  48. }
  49.  
  50. .valid:before {
  51. position: relative;
  52. left: -35px;
  53. content: "✔";
  54. }
  55.  
  56. /* Add a red text color and an "x" when the requirements are wrong */
  57. .invalid {
  58. color: red;
  59. }
  60.  
  61. .invalid:before {
  62. position: relative;
  63. left: -35px;
  64. content: "✖";
  65. }
  66. </style>
  67. </head>
  68. <body>
  69.  
  70. <h3>Please fill in ALL info.</h3>
  71. <p>When Finished, enter the form by clicking submit</p>
  72.  
  73. <div class="container">
  74. <form action="file:///home/chronos/u-be50812bb7210c63a5b9a16b6816355f75f82c2f/Downloads/My%20Websites/redirectpage.html">
  75. <label for="usrname">Username</label>
  76. <input type="text" id="usrname" name="usrname" required>
  77.  
  78. <label for="psw">Password</label>
  79. <input type="password" id="psw" name="psw" pattern="(?=.*d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required>
  80.  
  81. <input type="submit" value="Submit">
  82. </form>
  83. </div>
  84.  
  85. <div id="message">
  86. <h3>Password must contain the following:</h3>
  87. <p id="letter" class="invalid">A <b>lowercase</b> letter</p>
  88. <p id="capital" class="invalid">A <b>capital (uppercase)</b> letter</p>
  89. <p id="number" class="invalid">A <b>number</b></p>
  90. <p id="length" class="invalid">Minimum <b>8 characters</b></p>
  91. </div>
  92.  
  93. <script>
  94. var myInput = document.getElementById("psw");
  95. var letter = document.getElementById("letter");
  96. var capital = document.getElementById("capital");
  97. var number = document.getElementById("number");
  98. var length = document.getElementById("length");
  99.  
  100. // When the user clicks on the password field, show the message box
  101. myInput.onfocus = function() {
  102. document.getElementById("message").style.display = "block";
  103. }
  104.  
  105. // When the user clicks outside of the password field, hide the message box
  106. myInput.onblur = function() {
  107. document.getElementById("message").style.display = "none";
  108. }
  109.  
  110. // When the user starts to type something inside the password field
  111. myInput.onkeyup = function() {
  112. // Validate lowercase letters
  113. var lowerCaseLetters = /[a-z]/g;
  114. if(myInput.value.match(lowerCaseLetters)) {
  115. letter.classList.remove("invalid");
  116. letter.classList.add("valid");
  117. } else {
  118. letter.classList.remove("valid");
  119. letter.classList.add("invalid");
  120. }
  121.  
  122. // Validate capital letters
  123. var upperCaseLetters = /[A-Z]/g;
  124. if(myInput.value.match(upperCaseLetters)) {
  125. capital.classList.remove("invalid");
  126. capital.classList.add("valid");
  127. } else {
  128. capital.classList.remove("valid");
  129. capital.classList.add("invalid");
  130. }
  131.  
  132. // Validate numbers
  133. var numbers = /[0-9]/g;
  134. if(myInput.value.match(numbers)) {
  135. number.classList.remove("invalid");
  136. number.classList.add("valid");
  137. } else {
  138. number.classList.remove("valid");
  139. number.classList.add("invalid");
  140. }
  141.  
  142. // Validate length
  143. if(myInput.value.length >= 8) {
  144. length.classList.remove("invalid");
  145. length.classList.add("valid");
  146. } else {
  147. length.classList.remove("valid");
  148. length.classList.add("invalid");
  149. }
  150. }
  151. </script>
  152.  
  153. </body>
  154. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement