ads
8 months ago
control
8 months ago
img
10 years ago
blocker.js
1 week ago
blocker.min.js
1 week ago
embed.js
5 years ago
embed.min.js
7 months ago
front.js
2 days ago
front.min.js
2 days ago
jquery-ui-timepicker-addon.js
10 years ago
jquery-ui-timepicker-addon.min.js
7 months ago
jquery.dataTables.min.js
1 year ago
jquery.validate.js
7 months ago
jquery.validate.min.js
1 week ago
jqueryFileTree.js
5 years ago
jqueryFileTree.min.js
7 months ago
overwatch.js
7 months ago
overwatch.min.js
7 months ago
password-strength.js
2 years ago
password-strength.min.js
7 months ago
simple-scrollbar.js
7 months ago
simple-scrollbar.min.js
7 months ago
simplebar.js
6 years ago
validator.min.js
9 years ago
vue.js
9 months ago
vue.min.js
9 months ago
wpdm-admin.js
1 week ago
wpdm-admin.min.js
1 week ago
wpdm.js
6 months ago
wpdm.min.js
6 months ago
password-strength.js
157 lines
| 1 | (function () { |
| 2 | "use strict"; |
| 3 | window.addEventListener( |
| 4 | "load", |
| 5 | function () { |
| 6 | // Fetch all the forms we want to apply custom Bootstrap validation styles to |
| 7 | var forms = document.getElementsByClassName("wpdm-registration-form"); |
| 8 | // Loop over them and prevent submission |
| 9 | var validation = Array.prototype.filter.call(forms, function (form) { |
| 10 | // making sure password enters the right characters |
| 11 | form.reg_password.addEventListener("keypress", function (event) { |
| 12 | console.log("keypress"); |
| 13 | console.log("event.which: " + event.which); |
| 14 | var checkx = true; |
| 15 | var chr = String.fromCharCode(event.which); |
| 16 | console.log("char: " + chr); |
| 17 | |
| 18 | var matchedCase = new Array(); |
| 19 | matchedCase.push("[!@#$%&*_?]"); // Special Charector |
| 20 | matchedCase.push("[A-Z]"); // Uppercase Alpabates |
| 21 | matchedCase.push("[0-9]"); // Numbers |
| 22 | matchedCase.push("[a-z]"); |
| 23 | |
| 24 | for (var i = 0; i < matchedCase.length; i++) { |
| 25 | if (new RegExp(matchedCase[i]).test(chr)) { |
| 26 | console.log("checkx: is true"); |
| 27 | checkx = false; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | if (form.reg_password.value.length >= 20) checkx = true; |
| 32 | |
| 33 | if (checkx) { |
| 34 | event.preventDefault(); |
| 35 | event.stopPropagation(); |
| 36 | } |
| 37 | }); |
| 38 | |
| 39 | //Validate Password to have more than 8 Characters and A capital Letter, small letter, number and special character |
| 40 | // Create an array and push all possible values that you want in password |
| 41 | var matchedCase = new Array(); |
| 42 | matchedCase.push("[$@$$!%*#?&]"); // Special Charector |
| 43 | matchedCase.push("[A-Z]"); // Uppercase Alpabates |
| 44 | matchedCase.push("[0-9]"); // Numbers |
| 45 | matchedCase.push("[a-z]"); // Lowercase Alphabates |
| 46 | |
| 47 | form.reg_password.addEventListener("keyup", function () { |
| 48 | var messageCase = new Array(); |
| 49 | messageCase.push(" Special Charector"); // Special Charector |
| 50 | messageCase.push(" Upper Case"); // Uppercase Alpabates |
| 51 | messageCase.push(" Numbers"); // Numbers |
| 52 | messageCase.push(" Lower Case"); // Lowercase Alphabates |
| 53 | |
| 54 | var ctr = 0; |
| 55 | var rti = ""; |
| 56 | for (var i = 0; i < matchedCase.length; i++) { |
| 57 | if ( |
| 58 | new RegExp(matchedCase[i]).test(form.reg_password.value) |
| 59 | ) { |
| 60 | if (i == 0) |
| 61 | messageCase.splice( |
| 62 | messageCase.indexOf(" Special Charector"), |
| 63 | 1 |
| 64 | ); |
| 65 | if (i == 1) |
| 66 | messageCase.splice(messageCase.indexOf(" Upper Case"), 1); |
| 67 | if (i == 2) |
| 68 | messageCase.splice(messageCase.indexOf(" Numbers"), 1); |
| 69 | if (i == 3) |
| 70 | messageCase.splice(messageCase.indexOf(" Lower Case"), 1); |
| 71 | ctr++; |
| 72 | //console.log(ctr); |
| 73 | //console.log(rti); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | //console.log(rti); |
| 78 | // Display it |
| 79 | var progressbar = 0; |
| 80 | var strength = ""; |
| 81 | var bClass = ""; |
| 82 | var $ = jQuery; |
| 83 | switch (ctr) { |
| 84 | case 0: |
| 85 | case 1: |
| 86 | strength = "Way too Weak"; |
| 87 | progressbar = 15; |
| 88 | bClass = "bg-danger"; |
| 89 | break; |
| 90 | case 2: |
| 91 | strength = "Very Weak"; |
| 92 | progressbar = 25; |
| 93 | bClass = "bg-danger"; |
| 94 | break; |
| 95 | case 3: |
| 96 | strength = "Weak"; |
| 97 | progressbar = 34; |
| 98 | bClass = "bg-warning"; |
| 99 | break; |
| 100 | case 4: |
| 101 | strength = "Medium"; |
| 102 | progressbar = 65; |
| 103 | bClass = "bg-warning"; |
| 104 | break; |
| 105 | } |
| 106 | |
| 107 | if ( |
| 108 | strength == "Medium" && |
| 109 | form.reg_password.value.length >= 6 |
| 110 | ) { |
| 111 | strength = "Strong"; |
| 112 | bClass = "bg-success"; |
| 113 | form.reg_password.setCustomValidity(""); |
| 114 | } else { |
| 115 | form.reg_password.setCustomValidity(strength); |
| 116 | } |
| 117 | |
| 118 | var sometext = ""; |
| 119 | |
| 120 | if (form.reg_password.value.length < 6) { |
| 121 | var lengthI = 6 - form.reg_password.value.length; |
| 122 | sometext += ` ${lengthI} more Characters, `; |
| 123 | } |
| 124 | |
| 125 | sometext += messageCase; |
| 126 | console.log(sometext); |
| 127 | |
| 128 | console.log(sometext); |
| 129 | |
| 130 | if (sometext) { |
| 131 | sometext = " You Need" + sometext; |
| 132 | } |
| 133 | |
| 134 | //$("#feedbackin, #feedbackirn").text(strength + sometext); |
| 135 | $("#progressbar") |
| 136 | .removeClass("bg-danger bg-warning bg-success") |
| 137 | .addClass(bClass); |
| 138 | var plength = form.reg_password.value.length; |
| 139 | if (plength > 0) progressbar += (plength - 0) * 1.75; |
| 140 | //console.log("plength: " + plength); |
| 141 | var percentage = progressbar + "%"; |
| 142 | form.reg_password.parentNode.classList.add("was-validated"); |
| 143 | //console.log("pacentage: " + percentage); |
| 144 | $("#progressbar").width(percentage); |
| 145 | |
| 146 | /*if (form.reg_password.checkValidity() === true) { |
| 147 | form.verifyPassword.disabled = false; |
| 148 | } else { |
| 149 | form.verifyPassword.disabled = true; |
| 150 | }*/ |
| 151 | }); |
| 152 | }); |
| 153 | }, |
| 154 | false |
| 155 | ); |
| 156 | })(); |
| 157 |