1 2function validateEMBG(embg) { 3 var i, sum,rez, rez2, res; 4 5 if(embg==""|| embg.length!=13){ 6 return false; 7 }else{ 8 sum; 9 res=1; 10 sum = 11 embg.charAt(0)*7+ 12 embg.charAt(1)*6+ 13 embg.charAt(2)*5+ 14 embg.charAt(3)*4+ 15 embg.charAt(4)*3+ 16 embg.charAt(5)*2+ 17 embg.charAt(6)*7+ 18 embg.charAt(7)*6+ 19 embg.charAt(8)*5+ 20 embg.charAt(9)*4+ 21 embg.charAt(10)*3+ 22 embg.charAt(11)*2; 23 24 rez = sum%11; 25 26 if(rez % 11 < 2) {rez = 11; } else { rez = rez % 11 ;} 27 28 rez2 = 11 - rez; 29 if(rez2 != embg.charAt(12)){ 30 res = 0; 31 /*console.log("EMBG is not valid"); */ 32 return false; 33 }else{ 34 /*console.log("VALID EMBG");*/ 35 if(embg.split('').every(char => char === embg[0])){ 36 return false; 37 }else{ 38 return true; 39 } 40 } 41 } 42} 43 44const checkEmbg = (embgEl) => { 45 let valid = false; 46 const min = 13, 47 max = 13; 48 const embg = embgEl.value.trim(); 49 if (!isRequired(embg)) { 50 showError(embgEl, 'ÐолеÑо\x20е\x20задолжиÑелно'); 51 } else if (!isBetween(embg.length, min, max)) { 52 showError(embgEl, 'ÐнеÑеÑе\x20валиден\x20ÐÐÐÐ') 53 } else if(!validateEMBG(embg)){ 54 showError(embgEl, 'ÐнеÑеÑе\x20валиден\x20ÐÐÐÐ') 55 } else { 56 showSuccess(embgEl); 57 valid = true; 58 } 59 return valid; 60} 61 62const checkMsisdn = (msisdnEl, msisdnFormat) => { 63 let valid = false; 64 const msisdn = msisdnEl.value.trim(); 65 if (!isRequired(msisdn)) { 66 showError(msisdnEl, 'ÐолеÑо\x20е\x20задолжиÑелно'); 67 }else if(!isMsisdnValid(msisdn, msisdnFormat)){ 68 showError(msisdnEl, 'ÐнеÑеÑе\x20валиден\x20ÑелеÑонÑки\x20бÑоÑ'); 69 } else { 70 showSuccess(msisdnEl); 71 valid = true; 72 } 73 return valid; 74} 75 76const checkEmail = (emailEl) => { 77 let valid = false; 78 const email = emailEl.value.trim(); 79 if (!isRequired(email)) { 80 showError(emailEl, 'ÐолеÑо\x20е\x20задолжиÑелно'); 81 } else if (!isEmailValid(email)) { 82 showError(emailEl, 'ÐнеÑеÑе\x20валидна\x20e-mail\x20адÑеÑа') 83 } else { 84 showSuccess(emailEl); 85 valid = true; 86 } 87 return valid; 88}; 89 90const checkPassword = (passwordEl) => { 91 let valid = false; 92 const password = passwordEl.value.trim(); 93 if (!isRequired(password)) { 94 showError(passwordEl, 'ÐолеÑо\x20е\x20задолжиÑелно'); 95 } else if (!isPasswordSecure(password)) { 96 showError(passwordEl, 'Ðевалидна\x20лозинка\x2e\x20ÐозинкаÑа\x20е\x20поÑÑебно\x20да\x20ÑодÑжи\x20голема\x20бÑква\x2c\x20мала\x20бÑква\x2c\x20ÑпеÑиÑален\x20знак\x2c\x20бÑоÑка\x20и\x20минимÑм\x208\x20каÑакÑеÑи\x2e\x20'); 97 } else { 98 showSuccess(passwordEl); 99 valid = true; 100 } 101 102 return valid; 103}; 104 105const checkConfirmPassword = (passwordEl, confirmPasswordEl) => { 106 let valid = false; 107 // check confirm password 108 const confirmPassword = confirmPasswordEl.value.trim(); 109 const password = passwordEl.value.trim(); 110 111 if (!isRequired(confirmPassword)) { 112 showError(confirmPasswordEl, 'ÐолеÑо\x20е\x20задолжиÑелно'); 113 } else if (password !== confirmPassword) { 114 showError(confirmPasswordEl, 'ÐозинкиÑе\x20не\x20Ñе\x20ÑовпаÑааÑ\x2c\x20обидеÑе\x20Ñе\x20повÑоÑно\x2e'); 115 } else { 116 showSuccess(confirmPasswordEl); 117 valid = true; 118 } 119 120 return valid; 121}; 122 123const isPasswordSecure = (password) => { 124 const re = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})"); 125 return re.test(password); 126}; 127 128const isEmailValid = (email) => { 129// const re = /[a-z0-9]+@[a-z]+\.[a-z]{2,3}/; 130 const re = /^(?!\d+@)\w+([-+.']\w+)*@(?!\d+\.)\w+([-.]\w+)*\.\w+([-.]\w+)*$/; 131 return re.test(email); 132};
133 134const isMsisdnValid = (msisdn, msisdnFormat) => { 135 if(msisdnFormat == "3897"){ 136 const re = /^3897\d{7}$/; 137 return re.test(msisdn); 138 }else if(msisdnFormat == "389"){ 139 const re = /^389\d{8}$/; 140 return re.test(msisdn); 141 }else if(msisdnFormat == "07"){ 142 const re = /^07\d{7}$/; 143 return re.test(msisdn); 144 }else if(msisdnFormat == "7"){ 145 const re = /^7\d{7}$/; 146 return re.test(msisdn); 147 }else{ 148 return false; 149 } 150 151} 152 153const isRequired = value => value === '' ? false : true; 154const isBetween = (length, min, max) => length < min || length > max ? false : true; 155const isValueBetween = (inputValue, min, max) => inputValue < min || inputValue > max ? false : true; 156 157const showError = (input, message) => { 158 // get the form-field element 159 const formField = input.parentElement; 160 // add the error class 161 formField.classList.remove('success'); 162 formField.classList.add('error'); 163 164 // show the error message 165 const error = formField.querySelector('small'); 166 error.textContent = message; 167}; 168 169const showSuccess = (input, message) => { 170 // get the form-field element 171 const formField = input.parentElement; 172 173 // remove the error class 174 formField.classList.remove('error'); 175 formField.classList.add('success'); 176 177 // hide the error message 178 const error = formField.querySelector('small'); 179 error.textContent = message; 180} 181 182function checkNumberFieldLength(elem, length){ 183 if (elem.value.length > length) { 184 elem.value = elem.value.slice(0,length); 185 } 186} 187 188$(".keep-default-value").keydown(function(event) { 189 var defaultValue = $(this).attr('defaultValue'); 190 191 if(!defaultValue) 192 defaultValue = '3897'; 193 194 if(event.key === 'Backspace' && event.ctrlKey){ 195 event.preventDefault(); 196 return; 197 }else if($(this).val() === defaultValue && (event.key === 'Backspace' || event.keyCode == 46)) { 198 event.preventDefault(); 199 return; 200 }else if(isTextSelected(this)){ 201 event.preventDefault(); 202 return; 203 } 204}); 205 206function isTextSelected(input) { 207 if (typeof input.selectionStart == "number") { 208 return input.selectionStart == 0 && input.selectionEnd == input.value.length; 209 } else if (typeof document.getSelection() != "undefined") { 210 input.focus(); 211 return document.getSelection() == input.value; 212 } 213} 214 215const inputsTel = document.querySelectorAll('input[type="tel"]'); 216for (const input of inputsTel) { 217 input.addEventListener("keypress", function (evt) { 218 if (evt.which != 8 && evt.which != 0 && evt.which < 48 || evt.which > 57) 219 { 220 evt.preventDefault(); 221 } 222 }); 223} 224 225const inputsNumber = document.querySelectorAll('input[type="number"]'); 226for (const input of inputsNumber) { 227 input.addEventListener("keypress", function (evt) { 228 if (evt.which != 8 && evt.which != 0 && evt.which < 48 || evt.which > 57) 229 { 230 evt.preventDefault(); 231 } 232 }); 233}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.