password.htm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <%+header%>
  2. <input type="password" aria-hidden="true" style="position:absolute; left:-10000px" />
  3. <script type="text/javascript">
  4. function checkPassword() {
  5. var pw1 = document.body.querySelector('[name="pw1"]');
  6. var view = document.getElementById("passstrength");
  7. var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
  8. var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
  9. var enoughRegex = new RegExp("(?=.{6,}).*", "g");
  10. if (false == enoughRegex.test(pw1.value)) {
  11. view.innerHTML = '<%:Password strength%>: <span style="color:red"><%:More Characters%></span>';
  12. } else if (strongRegex.test(pw1.value)) {
  13. view.innerHTML = '<%:Password strength%>: <span style="color:green"><%:Strong%></span>';
  14. } else if (mediumRegex.test(pw1.value)) {
  15. view.innerHTML = '<%:Password strength%>: <span style="color:orange"><%:Medium%></span>';
  16. } else {
  17. view.innerHTML = '<%:Password strength%>: <span style="color:red"><%:Weak%></span>';
  18. }
  19. return true;
  20. }
  21. </script>
  22. <div class="cbi-map">
  23. <h2><%:Router Password%></h2>
  24. <div class="cbi-section-descr">
  25. <%:Changes the administrator password for accessing the device%>
  26. </div>
  27. <div class="cbi-section-node">
  28. <div class="cbi-value">
  29. <label class="cbi-value-title" for="image"><%:Password%></label>
  30. <div class="cbi-value-field">
  31. <input type="password" name="pw1" onkeyup="checkPassword()"/><!--
  32. --><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button>
  33. </div>
  34. </div>
  35. <div class="cbi-value">
  36. <label class="cbi-value-title" for="image"><%:Confirmation%></label>
  37. <div class="cbi-value-field">
  38. <input type="password" name="pw2" onkeydown="if (event.keyCode === 13) submitPassword(event)" /><!--
  39. --><button class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" aria-label="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'">∗</button>
  40. <div id="passstrength" class="cbi-value-description"></div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="cbi-page-actions">
  46. <button class="btn cbi-button-apply" onclick="submitPassword(event)"><%:Save%></button>
  47. </div>
  48. <script type="application/javascript" src="<%=resource%>/view/system/password.js"></script>
  49. <%+footer%>