add_user.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $(function() {
  2. $('#v_email').change(function() {
  3. if($('#v_email_notify').prop('checked')){
  4. document.getElementById('v_notify').value = document.getElementById('v_email').value;
  5. }
  6. });
  7. $('#v_email_notify').change(function() {
  8. if($('#v_email_notify').prop('checked')){
  9. document.getElementById('v_notify').value = document.getElementById('v_email').value;
  10. }else{
  11. document.getElementById('v_notify').value = '';
  12. }
  13. });
  14. });
  15. randomString = function (min_length = 16) {
  16. $("input[name=v_password]").val(randomString2(min_length));
  17. App.Actions.WEB.update_v_password();
  18. };
  19. App.Actions.WEB.update_v_password = function (){
  20. var password = $('input[name="v_password"]').val();
  21. var min_small = new RegExp(/^(?=.*[a-z]).+$/);
  22. var min_cap = new RegExp(/^(?=.*[A-Z]).+$/);
  23. var min_num = new RegExp(/^(?=.*\d).+$/);
  24. var min_length = 8;
  25. var score = 0;
  26. if(password.length >= min_length) { score = score + 1; }
  27. if(min_small.test(password)) { score = score + 1;}
  28. if(min_cap.test(password)) { score = score + 1;}
  29. if(min_num.test(password)) { score = score+ 1; }
  30. $('#meter').val(score);
  31. }
  32. App.Listeners.WEB.keypress_v_password = function() {
  33. var ref = $('input[name="v_password"]');
  34. ref.bind('keypress input', function(evt) {
  35. clearTimeout(window.frp_usr_tmt);
  36. window.frp_usr_tmt = setTimeout(function() {
  37. var elm = $(evt.target);
  38. App.Actions.WEB.update_v_password(elm, $(elm).val());
  39. }, 100);
  40. });
  41. }
  42. App.Listeners.WEB.keypress_v_password();