cfpasswordstrength.tpl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script>
  2. jQuery(document).ready(function(){
  3. $("#btnCompleteProductConfig").prop("disabled",true);
  4. jQuery(":password").keyup(function () {
  5. var pwStrengthErrorThreshold = 50;
  6. var pwStrengthWarningThreshold = 75;
  7. var $newPassword1 = jQuery(":password");
  8. var pw = jQuery(":password").val();
  9. var pwlength = (pw.length);
  10. if (pwlength > 5) pwlength = 5;
  11. var numnumeric = pw.replace(/[0-9]/g, "");
  12. var numeric = (pw.length - numnumeric.length);
  13. if (numeric > 3) numeric = 3;
  14. var symbols = pw.replace(/\W/g, "");
  15. var numsymbols = (pw.length - symbols.length);
  16. if (numsymbols > 3) numsymbols = 3;
  17. var numupper = pw.replace(/[A-Z]/g, "");
  18. var upper = (pw.length - numupper.length);
  19. if (upper > 3) upper = 3;
  20. var pwstrength = ((pwlength * 10) - 20) + (numeric * 10) + (numsymbols * 15) + (upper * 10);
  21. if (pwstrength < 0) pwstrength = 0;
  22. if (pwstrength > 100) pwstrength = 100;
  23. $newPassword1.removeClass('has-error has-warning has-success');
  24. if (pwstrength < pwStrengthErrorThreshold) {
  25. $newPassword1.addClass('has-error');
  26. $newPassword1.css('background-color', '#f003');;
  27. } else if (pwstrength < pwStrengthWarningThreshold) {
  28. $newPassword1.addClass('has-warning');
  29. $newPassword1.css('background-color', '#ff03');;
  30. } else {
  31. $newPassword1.addClass('has-success');
  32. $newPassword1.css('background-color', '#0f03');;
  33. $("#btnCompleteProductConfig").removeProp("disabled");
  34. }
  35. });
  36. });
  37. </script>
  38. {if file_exists("templates/$template/includes/alert.tpl")}
  39. {include file="$template/includes/alert.tpl" type="info" msg="{$LANG.passwordtips}"}
  40. {elseif file_exists("templates/six/includes/alert.tpl")}
  41. {include file="six/includes/alert.tpl" type="info" msg="{$LANG.passwordtips}"}
  42. {/if}