1$(document).ready(function () { 2 var bank = $(document).find("#inputState"); 3 checkMask(bank); 4}); 5 6var bankLength = 0; 7 8// FORM VALIDATION 9document.addEventListener('DOMContentLoaded', function (e) { 10 const form = document.getElementById('registerForm'); 11 const fv = FormValidation.formValidation( 12 form, 13 { 14 fields: { 15 username: { 16 verbose: false, 17 validators: { 18 notEmpty: { 19 message: 'Kolom ini harus diisi' 20 }, 21 stringLength: { 22 min: 4, 23 max: 16, 24 message: 'Minimal 4 Karakter Maksimal 16 Karakter' 25 }, 26 remote: { 27 message: 'Nama pengguna telah di gunakan', 28 headers: { 29 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 30 }, 31 method: 'POST', 32 url: location.origin + '/register/check_user', 33 delay: 1000, 34 data: function () { 35 return { 36 'username': $('#username').val() 37 }; 38 }, 39 }, 40 } 41 }, 42 password: { 43 validators: { 44 notEmpty: { 45 message: 'Kolom ini harus diisi' 46 }, 47 remote: { 48 url: location.origin + '/register/check_password', 49 delay: 1000, 50 data: function () { 51 return { 52 'username': $("#username").val() 53 }; 54 }, 55 message: ' ' 56 }, 57 } 58 }, 59 password_confirmation: { 60 validators: { 61 notEmpty: { 62 message: 'Kolom ini harus diisi' 63 }, 64 identical: { 65 compare: function () { 66 return form.querySelector('[name="password"]').value; 67 }, 68 message: 'Harus sama dengan kolom password' 69 } 70 } 71 }, 72 email: { 73 icon: true, 74 validators: { 75 notEmpty: { 76 message: 'Kolom ini harus diisi' 77 }, 78 emailAddress: { 79 message: 'Isi dengan email yang valid' 80 } 81 } 82 }, 83 phone_number: { 84 validators: { 85 digits: { 86 message: 'Isi hanya dengan angka' 87 }, 88 notEmpty: { 89 message: 'Kolom ini harus diisi' 90 }, 91 stringLength: { 92 min: 8, 93 max: 13, 94 message: 'Isi dengan panjang 8 - 13 karakter' 95 } 96 } 97 }, 98 account_name: { 99 validators: { 100 notEmpty: { 101 message: 'Kolom ini harus diisi' 102 }, 103 stringLength: { 104 min: 3, 105 message: 'Minimal 3 karakter' 106 } 107 } 108 }, 109 account_number: { 110 validators: { 111 notEmpty: { 112 message: 'Kolom ini harus diisi' 113 }, 114 callback: { 115 message: 'Jumlah digit tidak sesuai', 116 callback: function (input) { 117 const value = input.value; 118 const cleanValue = value.replace(/[^0-9]/g, ''); 119 if (minDigit === 0) return true; 120 121 if (cleanValue.length < minDigit || cleanValue.length > maxDigit) { 122 let errorMsg = ''; 123 if (minDigit === maxDigit) { 124 errorMsg = 'Harus pas ' + minDigit + ' digit angka.'; 125 } else { 126 errorMsg = 'Harus antara ' + minDigit + ' sampai ' + maxDigit + ' digit angka.'; 127 } 128 129 return { 130 valid: false, 131 message: errorMsg + ' (Terisi: ' + cleanValue.length + ')' 132 }; 133 } 134 return true; 135 } 136 }, 137 remote: { 138 message: 'Nomor rekening/HP sudah digunakan', 139 headers: { 140 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 141 }, 142 method: 'POST', 143 url: location.origin + '/register/check_bank_account', 144 delay: 1000, 145 data: function () { 146 return { 147 'account_number': $("input[name=account_number]").val(), 148 'bank_name': $("#inputState").val() 149 }; 150 }, 151 }, 152 } 153 }, 154 validation_code: { 155 validators: { 156 notEmpty: { 157 message: 'Kolom ini harus diisi' 158 },
159 stringLength: { 160 min: 4, 161 message: 'Minimal 4 karakter' 162 } 163 } 164 } 165 }, 166 plugins: { 167 trigger: new FormValidation.plugins.Trigger(), 168 bootstrap: new FormValidation.plugins.Bootstrap({ 169 defaultMessageContainer: false, 170 }), 171 submitButton: new FormValidation.plugins.SubmitButton(), 172 defaultSubmit: new FormValidation.plugins.DefaultSubmit(), 173 message: new FormValidation.plugins.Message({ 174 clazz: "fv-help-block", 175 container: function (field, ele) { 176 if (field === "phone_number") { 177 if (FormValidation.utils.closest(ele, '.col-sm-8')) { 178 return FormValidation.utils.closest(ele, '.col-sm-8').nextElementSibling; 179 } 180 return FormValidation.utils.closest(ele, '.input-group'); 181 } 182 return FormValidation.utils.closest(ele, '.form-group'); 183 }, 184 }), 185 }, 186 } 187 ); 188 189 fv.on('core.element.validating', function (event) { 190 let message; 191 let lengthbank = bankLength; 192 message = 'minimal Input ' + bankLength + ' number'; 193 // Update message 194 if (event.element.getAttribute('id') == 'account_number') { 195 if (event.element.value.match(/[0-9]/)) { 196 if (event.element.value.replace(/-/g, '').length < bankLength) { 197 var el = event.element.value.match(/-/g) 198 if (el) lengthbank = el.length - bankLength; 199 fv.updateValidatorOption('account_number', 'stringLength', 'message', message); 200 event.element.setAttribute('minlength', lengthbank); 201 fv.updateValidatorOption("account_number", "stringLength", "min", lengthbank); 202 } 203 } else { 204 event.element.value = ''; 205 } 206 } 207 }); 208 209 $(document).on("change", "#inputState", function () { 210 fv.revalidateField('account_number'); 211 }); 212 213 fv.on('core.form.valid', function () { 214 btnLoadReg(true); 215 window.register($('#registerForm').serialize()) 216 }); 217}); 218// END FORM VALIDATION 219$('#register-pops').modal('hide'); 220 221const telebot = $('.telebot').val(); 222// AJAX REGISTER 223window.register = function (serialize) { 224 $.ajax({ 225 url: location.origin + '/register/submit', 226 method: 'post', 227 data: serialize, 228 success: function success(response) { 229 if (response.status === "success") { 230 if (telebot == 'webapps') { 231 $('#register-pops').modal('show'); 232 window.Telegram.WebApp.sendData(JSON.stringify(response)); 233 setTimeout(function () { 234 window.Telegram.WebApp.close(); 235 }, 5000); 236 } else { 237 buzzer({ 238 status: "success", 239 msg: response.message 240 }); 241 setTimeout(function () { 242 window.location = '/register/success'; 243 }, 2000); 244 } 245 246 } else { 247 $.each(response.errors, function (index, value) { 248 buzzer({ 249 status: "error", 250 msg: value 251 }); 252 }); 253 var rand = Math.random(); 254 $('#captcha_register').attr('src', '/captcha/default?' + rand); 255 $('.validation_code').val(''); 256 btnLoadReg(false); 257 } 258 }, 259 error: function error(e) { 260 btnLoadReg(false); 261 buzzer({ 262 status: "error", 263 msg: 'Something when wrong, please try again.' 264 }); 265 } 266 }); 267}; 268
269function btnLoadReg($con) { 270 if ($con) { 271 $(document).find('.registerButton').attr('disabled', true); 272 $(document).find('.registerButton').text('Loading...'); 273 } else { 274 console.log('btnloadgabisa'); 275 $(document).find('.registerButton').attr('disabled', false); 276 $(document).find('.registerButton').text('Submit'); 277 278 } 279} 280 281$(document).on("click", "#re-captcha", function () { 282 $(document).find('#captcha_register').attr('src', '/captcha/default?' + Math.random()); 283}); 284 285$(document).on('keyup', '#telephoneCheck', function () { 286 let value = $(this).val(); 287 if (value.length > 0 && value.length < 2) { 288 if (value == '0') { 289 $(this).val(''); 290 } 291 } 292 293 let validate = /^[0-9]+$/.test(value); 294 if (validate == false) { 295 value = value.split(''); 296 value.pop(); 297 value = value.join(''); 298 $(this).val(value); 299 } 300}); 301 302$(document).on("change", "#inputState", function () { 303 checkMask($(this)); 304}); 305 306function checkMask(element) { 307 var bankName = element.val(); 308 if (!bankName) return; 309 310 bankName = bankName.toUpperCase(); 311 console.log("Selected Bank:", bankName); 312 313 $("#account_number").val(''); 314 $("#account_name").val(''); 315 removeAttr('#account_number'); 316 attrUpDownString('#account_name'); 317 318 minDigit = 0; 319 maxDigit = 0; 320 321 if (bankName == "BCA") { 322 $("#account_number").mask("999-999-9999"); 323 minDigit = 10; maxDigit = 10; 324 } else if (bankName == "MANDIRI") { 325 $("#account_number").mask("999-99-9999-9999"); 326 minDigit = 13; maxDigit = 13; 327 } else if (bankName == "BNI") { 328 $("#account_number").mask("999-999-9999"); 329 minDigit = 10; maxDigit = 10; 330 } else if (bankName == "BRI") { 331 $("#account_number").mask("999-99-9999-9999-99"); 332 minDigit = 15; maxDigit = 15; 333 } else if (bankName == "CIMB") { 334 $("#account_number").mask("999-99-9999-999"); 335 minDigit = 10; maxDigit = 13; 336 } else if (bankName == "PERMATA" || bankName == "MAYBANK" || bankName == "PANIN" || bankName == "SINARMAS") { 337 $("#account_number").mask("999-999-9999"); 338 minDigit = 10; maxDigit = 10; 339 } else if (bankName == "MEGA") { 340 $("#account_number").mask("999-99-9999-9999-99"); 341 minDigit = 15; maxDigit = 15; 342 } else if (bankName == "JENIUS") { 343 $("#account_number").mask("999-9999-9999"); 344 minDigit = 11; maxDigit = 11; 345 } else if (bankName == "OCBC" || bankName == "DANAMON") { 346 $("#account_number").mask("999-99-9999-9999"); 347 minDigit = 13; maxDigit = 13; 348 } else if (bankName == "BSI") { 349 $("#account_number").mask("999-99-9999-9999"); 350 minDigit = 10; maxDigit = 13; 351 } else if (bankName == "OVO" || bankName == "DANA" || bankName == "GOPAY" || bankName == "SHOPEEPAY") { 352 $("#account_number").mask("0000-0000-00000"); 353 minDigit = 10; 354 maxDigit = 13; 355 } 356 357 else if (bankName == "GJK") { 358 $("#account_number").unmask(); 359 removeAttr('#account_name'); 360 attrUpDownNumber('#account_number'); 361 minDigit = 10; maxDigit = 10; 362 } else { 363 $("#account_number").unmask(); 364 minDigit = 10; maxDigit = 20; 365 } 366} 367 368function removeAttr(id) { 369 console.log($(id).val()) 370 $(id).removeAttr('onkeyup onkeydown'); 371} 372 373function attrUpDownNumber(id) { 374 console.log($(id).val()) 375 $(id).attr({ 376 onkeydown: "this.value=this.value.replace(/[^0-9]/g,'');", 377 onkeyup: "this.value=this.value.replace(/[^0-9]/g,'');" 378 }); 379} 380 381function attrUpDownString(id) { 382 console.log($(id).val(), $(id).val().replace(/[^a-zA-Z\s ]/, '')); 383 $(id).attr({ 384 onkeydown: "this.value=this.value.replace(/[^a-zA-Z ]/g,'');", 385 onkeyup: "this.value=this.value.replace(/[^a-zA-Z ]/g,'');" 386 }); 387}
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.