1$ = jQuery.noConflict(); 2var http = getHTTPObject(); 3var calDiv = ''; 4/* Ajax Functionality */ 5function getHTTPObject() { 6 var xmlhttp; 7 if (window.XMLHttpRequest) { 8 xmlhttp = new XMLHttpRequest(); 9 } else if (window.ActiveXObject) { 10 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 11 if (!xmlhttp) { 12 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 13 } 14 } 15 return xmlhttp; 16} 17$(function () { 18 var token = $("meta[name='_csrf']").attr("content"); 19 var header = $("meta[name='_csrf_header']").attr("content"); 20 $(document).ajaxSend(function(e, xhr, options) { 21 xhr.setRequestHeader(header, token); 22 }); 23}); 24 25// Trim Function 26function trim(text) { 27 return (text || "").replace(/^\s+|\s+$/g, ""); 28} 29 30/* Locale-aware name char regex â built once from window.bbNameCharBlocks; used by 31 keyRestrict('localeName') and validateLocaleNamePaste. */ 32var localeNameAllowRegex = null; 33function getLocaleNameAllowRegex() { 34 if (localeNameAllowRegex === null) { 35 var extras = window.bbNameCharBlocks || ''; 36 localeNameAllowRegex = new RegExp('[a-zA-Z' + extras + ' ]'); 37 } 38 return localeNameAllowRegex; 39} 40var localeNameFullRegex = null; 41function getLocaleNameFullRegex() { 42 if (localeNameFullRegex === null) { 43 var extras = window.bbNameCharBlocks || ''; 44 localeNameFullRegex = new RegExp('^[a-zA-Z' + extras + ' ]*$'); 45 } 46 return localeNameFullRegex; 47} 48 49/* Key Restrictions */ 50function keyRestrict(e, choice) { 51 if (choice == 'localeName') { 52 var lnKey = getKeyCode(e); 53 if (lnKey == null) return true; 54 if (lnKey == 0 || lnKey == 8 || lnKey == 9 || lnKey == 13 || lnKey == 27) return true; 55 return getLocaleNameAllowRegex().test(String.fromCharCode(lnKey)); 56 } 57 validchars = ''; 58 if (choice == 'int') 59 validchars = '1234567890'; 60 else if (choice == 'dotint') 61 validchars = '1234567890.'; 62 else if (choice == 'date') 63 validchars = '1234567890-/'; 64 else if (choice == 'time') 65 validchars = '1234567890:ampm'; 66 else if (choice == 'phone') 67 validchars = '1234567890'; 68 else if (choice == 'char') 69 validchars = 'abcdefghijklmnopqrstuvwxyz '; 70 else if (choice == 'charspe') 71 validchars = 'abcdefghijklmnopqrstuvwxyz_.'; 72 else if (choice == 'emailchar') 73 validchars = 'abcdefghijklmnopqrstuvwxyz_-.1234567890@'; 74 else if (choice == 'ccEmailchar') 75 validchars = 'abcdefghijklmnopqrstuvwxyz_-.1234567890@, '; 76 else if (choice == 'passchar') 77 validchars = 'abcdefghijklmnopqrstuvwxyz_1234567890.'; 78 else if (choice == 'charspace') 79 validchars = 'abcdefghijklmnopqrstuvwxyz1234567890 '; 80 else if (choice == 'zip') 81 validchars = 'abcdefghijklmnopqrstuvwxyz1234567890- '; 82 else if (choice == 'alphaNum') 83 validchars = 'abcdefghijklmnopqrstuvwxyz1234567890'; 84 else if (choice == 'vchar') 85 validchars = 'abcdefghijklmnopqrstuvwxyz1234567890 ._-@,#|:;$'; 86 else if (choice == 'price') 87 validchars = '1234567890.$'; 88 else if (choice == 'textbox') 89 validchars = 'abcdefghijklmnopqrstuvwxyz1234567890-.?!, '; 90 91 var key = '', keychar = ''; 92 key = getKeyCode(e); 93 if (key == null) 94 return true; 95 keychar = String.fromCharCode(key); 96 keychar = keychar.toLowerCase(); 97 validchars = validchars.toLowerCase(); 98 if (validchars.indexOf(keychar) != -1) 99 return true; 100 if (key == null || key == 0 || key == 8 || key == 9 || key == 13 101 || key == 27) 102 return true; 103 return false; 104} 105 106/* Form Inputs Validations*/ 107$('#phone').keyup(function() { 108 let val = $(this).val().replace(/\D/g, ''); 109 $(this).val(val.replace(new RegExp($(this).data('format-regex')), $(this).data('format-replace'))); 110}); 111 112/* Forms on paste validations */ 113function validateAlphaPaste(e) { 114 var regex = /^[a-zA-Z ]*$/; 115 var copiedText = e.clipboardData.getData('text') 116 if (!regex.test(copiedText)) { 117 e.preventDefault(); //this line executes only if copiedText has all invalid characters 118 return false; 119 } 120} 121 122function validateLocaleNamePaste(e) { 123 var copiedText = e.clipboardData.getData('text'); 124 if (!getLocaleNameFullRegex().test(copiedText)) { 125 e.preventDefault(); 126 return false; 127 } 128} 129 130function validateAlphaNumPaste(e) { 131 var regex = /^[a-zA-Z0-9 ]*$/; 132 var copiedText = e.clipboardData.getData('text') 133 if (!regex.test(copiedText)) { 134 e.preventDefault();
134 //this line executes only if copiedText has all invalid characters 135 return false; 136 } 137} 138 139function validateEmailPaste(e) { 140 var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; 141 var copiedText = e.clipboardData.getData('text') 142 if (!regex.test(copiedText)) { 143 e.preventDefault(); //this line executes only if copiedText has all invalid characters 144 return false; 145 } 146} 147 148function validateNumPaste(e) { 149 var regex = /^([0-9 \(\)\-]{2,14})$/; 150 var copiedText = e.clipboardData.getData('text') 151 if (!regex.test(copiedText)) { 152 e.preventDefault(); //this line executes only if copiedText has all invalid characters 153 return false; 154 } 155} 156 157function validateZipPaste(e) { 158 var regex = /^[a-zA-Z0-9 ]*$/; 159 var copiedText = e.clipboardData.getData('text') 160 if (!regex.test(copiedText)) { 161 e.preventDefault(); //this line executes only if copiedText has all invalid characters 162 return false; 163 } 164} 165/* End Form Inputs Validations*/ 166 167/* hyphen for US postal codes after 5 digits */ 168$('#zipcode, #zipcodeLocalCenter').keydown(function(e) { 169 if((e.keyCode==189 || e.keyCode==109) && $(this).val().length != 5){ 170 return false; 171 } 172 if(e.keyCode==32 && $(this).val().length < 3){ 173 return false; 174 } 175}); 176 177/* End hyphen for US postal codes after 5 digits */ 178 179 180function keybutton(e) { 181 if (window.event) { /* IE */ 182 keynum = e.keyCode; 183 } else if (e.which) { /* Netscape/Firefox/Opera */ 184 keynum = e.which; 185 } 186 if (keynum == 13) { 187 centerLocator(); 188 } 189} 190 191function getKeyCode(e) { 192 if (window.event) { 193 return window.event.keyCode; 194 } else if (e) { 195 return e.which; 196 } else { 197 return null; 198 } 199} 200 201var testresults; 202function checkemail(emailCheck) { 203 emailCheck = trim(emailCheck); 204 var filter = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
205 if (emailCheck == undefined || emailCheck == 'undefined' || emailCheck == '') { 206 testresults = false; 207 } else if (filter.test(emailCheck)) { 208 testresults = true; 209 } else { 210 testresults = false; 211 } 212 return (testresults); 213} 214function checkphone(phoneCheck) { 215 var filter = new RegExp($('#phone').data('validate-regex')); 216 console.log(phoneCheck); 217 if (phoneCheck == undefined || phoneCheck == 'undefined' || phoneCheck == '') { 218 testresults = false; 219 } else if (filter.test(phoneCheck)) { 220 testresults = true; 221 } else { 222 testresults = false; 223 } 224 return (testresults); 225} 226 227function valStr(stringCheck) { 228 stringCheck = trim(stringCheck); 229 if (stringCheck == undefined || stringCheck == 'undefined' || stringCheck == '') { 230 testresults = false; 231 } else { 232 testresults = true; 233 } 234 return (testresults); 235} 236 237function valInt(intCheck) { 238 intCheck = trim(intCheck); 239 if (intCheck == undefined || intCheck == 'undefined' || intCheck == '' || intCheck == '0') { 240 testresults = false; 241 } else { 242 testresults = true; 243 } 244 return (testresults); 245} 246 247function isCanadaPostalCode(PostalCode) { 248 var postalCodePattern = /^([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z](\s)?\d?[A-Za-z]?\d?)$/gi; 249 return postalCodePattern.test($.trim(PostalCode)); 250} 251 252function isUSPostalCode(PostalCode) { 253 var postalCodePattern = /^(\d{5}(( |-)\d{4})?)$/gi; 254 return postalCodePattern.test($.trim(PostalCode)); 255} 256 257function isIndiaPostalCode(PostalCode) { 258 var postalCodePattern = /^[1-9]\d{5}?$/gi; 259 return postalCodePattern.test($.trim(PostalCode)); 260} 261 262function isAustraliaPostCode(PostCode) { 263 var postalCodePattern = /^\d{4}?$/gi; 264 return postalCodePattern.test($.trim(PostCode)); 265} 266 267/*$(document).ready(function() { 268 $('#saveContactusFormButton').click(function() { 269 saveContactus(); 270 }); 271 $('#saveCarryOurBeersFormButton').click(function() { 272 saveCarryOurBeers(); 273 });
274 $('#saveSpbcAmbassadorFormButton').click(function() { 275 saveSpbcAmbassador(); 276 }); 277 278 279});*/ 280 281function checkRadioById(id) { 282 var isChecked = $('#' + id + ':checked').val() ? true : false; 283 return isChecked; 284} 285 286function showError(message) { 287 try { 288 $(".main-container").addClass("bfixed"); 289 $("body").addClass("popup-added"); 290 $('#eMsg').html(message); 291 $('#failure').css("display", "flex"); 292 } catch (e) { 293 alert(e); 294 } 295} 296 297 298function showPackageError(message) { 299 try { 300 $(".main-container").addClass("bfixed"); 301 $("body").addClass("popup-added"); 302 $('#failure .error-msg').html(message); 303 $('#failure').css("display", "flex"); 304 } catch (e) { 305 alert(e); 306 } 307} 308 309function showSucess(message) { 310 try { 311 $(".main-container").addClass("bfixed"); 312 $('#sMsg').html(message); 313 $('#success').show(); 314 } catch (e) { 315 alert(e); 316 } 317} 318 319function showInlineError(message) { 320 $('#eMsg').html(message); 321 if ($(".error-msg").html().length > 0) { 322 $(this).removeClass("hidden"); 323 } else { 324 $(this).addClass("hidden"); 325 } 326} 327 328function logout() { 329 document.logout.submit(); 330} 331 332function load(lurl) { 333 window.location.href = lurl; 334} 335 336function login() { 337 $('#loading').show(); 338 var loginName = $('#loginName').val(); 339 var password = $('#password').val(); 340 var message = ''; 341 if (checkemail(loginName) && valStr(password)) { 342 document.loginForm.submit(); 343 $('#loading').hide(); 344 } else { 345 if (!checkemail(loginName)) { 346 message += '<li>Please provide valid login email ID</li>'; 347 } 348 if (!valStr(password)) { 349 message += '<li>Please provide valid password</li>'; 350 } 351 if (message != '') { 352 $('#loading').hide(); 353 showError(message); 354 return false; 355 } 356 } 357} 358 359function validateCaptcha() { 360 var loginName = $('#loginName').val(); 361 if (checkemail(loginName)) { 362 document.forgotpasswordform.submit(); 363 } else { 364 $('#loading').hide(); 365 showError('<li>Please provide email ID</li>'); 366 } 367} 368 369function resetPw() { 370 $('#loading').show(); 371 var loginName = $('#loginName').val(); 372 var securitycode = $('#securitycode').val(); 373 var password = $('#password').val(); 374 var retypePassword = $('#retypePassword').val(); 375 var message = ''; 376 if (!checkemail(loginName)) { 377 message += '<li>Please provide email ID</li>'; 378 } 379 if (!valStr(securitycode)) { 380 message += '<li>Please provide the security code you recieved</li>'; 381 } 382 if (!valStr(password)) { 383 message += '<li>Please provide password !!\n</li>'; 384 } 385 if (!valStr(retypePassword)) { 386 message += '<li>Please re-enter the above password to confirm</li>'; 387 } 388 if (message != '') { 389 $('#loading').hide(); 390 showError(message); 391 } else { 392 if (password != retypePassword) { 393 showError('<li>Retype password does not match with the password</li>'); 394 } else { 395 $('#loading').hide(); 396 document.passwordresetform.submit(); 397 } 398 } 399} 400 401 402function saveContactUs() { 403 try { 404 405 $( "form .error-block" ).removeClass("error-block"); 406 $( ".error-msg" ).addClass("hidden"); 407 $( ".form-control" ).siblings(".error-msg").text( "" ); 408 $( "#formCaptcha" ).siblings(".error-msg").text( "" ); 409 $(".location-selection-error").text( "" ); 410 411 $('#loading').fadeIn(); 412 /*var locality = trim($('#locality').val()); 413 var selectedAddress = trim($('#google-address').val());*/ 414 415 416 var firstName = $('#firstName').val(); 417 var lastName = $('#lastName').val(); 418 var email = $('#email').val(); 419 var phone = $('#phone').val(); 420 var message = $('#message').val(); 421 var zipcode = $('#zipcode').val(); 422 var pageName = $('#pageName').val(); 423 var trace = $('#trace').val(); 424 var locationId = $('#locationId').val(); 425 var v = grecaptcha.getResponse(formCaptchaWidId); 426 var errMsg = ''; 427 428 429 /*if (locality == undefined || locality == 'undefined' || locality == '' || selectedAddress == '') { 430 $( "#locality" ).parent().addClass("error-block").children(".error-msg").text( "Please Type and Select address from dropdown." ); 431 errMsg += $( "#locality" ).siblings(".error-msg").text(); 432 }*/ 433 434 if (!valStr(firstName)) { 435 $( "#firstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 436 errMsg += $( "#firstName" ).siblings(".error-msg").text(); 437 } 438 if (!valStr(lastName)) { 439 $( "#lastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 440 errMsg += $( "#lastName" ).siblings(".error-msg").text(); 441 } 442 if (!checkemail(email)) { 443 $( "#email" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.email.address") ); 444 errMsg += $( "#email" ).siblings(".error-msg").text(); 445 } 446 if (!checkphone(phone)) { 447 $( "#phone" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.phone.number") ); 448 errMsg += $( "#phone" ).siblings(".error-msg").text(); 449 } 450 if (!valStr(zipcode)) { 451 $( "#zipcode" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 452 errMsg += $( "#zipcode" ).siblings(".error-msg").text(); 453 } 454 if (!valStr(locationId) && !window.bbNoLocationMode) { 455 $( "#locationId" ).parent().addClass("error-block").children(".error-msg").text( t("choose.a.location") ); 456 errMsg += $( "#locationId" ).siblings(".error-msg").text(); 457 } 458 if (!valStr(message) || message.length < 10 ) { 459 $( "#message" ).parent().addClass("error-block").children(".error-msg").text( t("enter.min.ten.characters") ); 460 errMsg += $( "#message" ).siblings(".error-msg").text(); 461 } 462 if (!valStr(pageName)) { 463 $( "#pageName" ).parent().addClass("error-block").children(".error-msg").text( t("error.occuring.try.again") ); 464 errMsg += $( "#pageName" ).siblings(".error-msg").text(); 465 } 466 if (!valStr(trace)) { 467 $( "#trace" ).parent().addClass("error-block").children(".error-msg").text( t("error.occuring.try.again") ); 468 errMsg += $( "#trace" ).siblings(".error-msg").text(); 469 } 470 if (v.length == 0) { 471 $( "#formCaptcha" ).parent().addClass("error-block").children(".error-msg").text( t("missed.captcha") ); 472 errMsg += $( "#formCaptcha" ).siblings(".error-msg").text(); 473 } 474 if($('#receivePromotionalMails').is(':checked')){ 475 $('#receivePromotionalMails').val('true'); 476 } else{ 477 $('#receivePromotionalMails').val('false'); 478 } 479 $('#gRecaptchaResponse').val(v); 480 if (errMsg != '') { 481 showInlineError(errMsg); 482 $("html, body").animate({ scrollTop: 0 }); 483 $('#loading').fadeOut(500); 484 grecaptcha.reset(formCaptchaWidId); 485 } else { 486 $('#loading').show(); 487 document.saveContactUsForm.submit(); 488 grecaptcha.reset(formCaptchaWidId); 489 } 490 491 } catch (e) { 492 return false; 493 } 494} 495 496function savePromotionsContactUs() { 497 try { 498 499 $( "form .error-block" ).removeClass("error-block"); 500 $( ".error-msg" ).addClass("hidden"); 501 $( ".form-control" ).siblings(".error-msg").text( "" ); 502 $( "#formCaptcha" ).siblings(".error-msg").text( "" ); 503 $(".location-selection-error").text( "" ); 504 $('#loading').fadeIn(); 505 /*var locality = trim($('#locality').val()); 506 var selectedAddress = trim($('#google-address').val());*/ 507 var firstName = $('#firstName').val(); 508 var lastName = $('#lastName').val(); 509 var email = $('#email').val(); 510 var phone = $('#phone').val(); 511 var message = $('#message').val(); 512 var zipcode = $('#zipcode').val(); 513 var trace = $('#trace').val(); 514 var locationId = $('#locationId').val(); 515 var v = grecaptcha.getResponse(formCaptchaWidId); 516 var errMsg = ''; 517 518 519 /*if (locality == undefined || locality == 'undefined' || locality == '' || selectedAddress == '') { 520 $( "#locality" ).parent().addClass("error-block").children(".error-msg").text( "Please Type and Select address from dropdown." ); 521 errMsg += $( "#locality" ).siblings(".error-msg").text(); 522 }*/ 523 if (!valStr(firstName)) { 524 $( "#firstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 525 errMsg += $( "#firstName" ).siblings(".error-msg").text(); 526 } 527 if (!valStr(lastName)) { 528 $( "#lastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 529 errMsg += $( "#lastName" ).siblings(".error-msg").text(); 530 } 531 if (!checkemail(email)) { 532 $( "#email" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.email.address") ); 533 errMsg += $( "#email" ).siblings(".error-msg").text(); 534 } 535 if (!checkphone(phone)) { 536 $( "#phone" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.phone.number") ); 537 errMsg += $( "#phone" ).siblings(".error-msg").text(); 538 } 539 if (!valStr(zipcode)) { 540 $( "#zipcode" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 541 errMsg += $( "#zipcode" ).siblings(".error-msg").text(); 542 } 543 if (!valStr(locationId) && !window.bbNoLocationMode) { 544 $( "#locationId" ).parent().addClass("error-block").children(".error-msg").text( t("choose.a.location") ); 545 errMsg += $( "#locationId" ).siblings(".error-msg").text(); 546 } 547 if (!valStr(message) || message.length < 10 ) { 548 $( "#message" ).parent().addClass("error-block").children(".error-msg").text( t("enter.min.ten.characters") ); 549 errMsg += $( "#message" ).siblings(".error-msg").text(); 550 } 551 if (!valStr(trace)) { 552 $( "#trace" ).parent().addClass("error-block").children(".error-msg").text( t("error.occuring.try.again") ); 553 errMsg += $( "#trace" ).siblings(".error-msg").text(); 554 } 555 if (v.length == 0) { 556 $( "#formCaptcha" ).parent().addClass("error-block").children(".error-msg").text( t("missed.captcha") ); 557 errMsg += $( "#formCaptcha" ).siblings(".error-msg").text(); 558 } 559 if($('#receivePromotionalMails').is(':checked')){ 560 $('#receivePromotionalMails').val('true'); 561 } else{ 562 $('#receivePromotionalMails').val('false'); 563 } 564 $('#gRecaptchaResponse').val(v); 565 if (errMsg != '') { 566 showInlineError(errMsg); 567 $("html, body").animate({ scrollTop: 0 }); 568 $('#loading').fadeOut(500); 569 grecaptcha.reset(formCaptchaWidId); 570 } else { 571 $('#loading').show(); 572 document.savepromotionsContactUsForm.submit(); 573 grecaptcha.reset(formCaptchaWidId); 574 } 575 576 } catch (e) { 577 return false; 578 } 579} 580 581 582/* Common Scripts */ 583$(".applylink").click(function() {
584 $("#applyForm").show(); 585 $(".applylink .label i").hide(); 586}); 587$(".apply-close").click(function() { 588 $("#applyForm").hide(); 589 $(".applylink .label i").show(); 590}); 591 592$(".request-info-form-btn").click(function() { 593 $(".request-info-form").show(); 594 $('body').addClass('body-fixed'); 595}); 596$(".request-info-form-close").click(function() { 597 $(".request-info-form").hide(); 598 $('body').removeClass('body-fixed'); 599}); 600 601$("#menu_btn").click(function() { 602 $("#sub_menu").slideToggle("slow"); 603}); 604$('#phoneNo').keyup(function() { 605 this.value = this.value.replace(/[^0-9\.() +-]/g, ''); 606}); 607$('#phone').keyup(function() { 608 this.value = this.value.replace(/[^0-9\.() +-]/g, ''); 609}); 610$('#emailId').keyup(function() { 611 this.value = this.value.replace(/[^a-zA-Z0-9\.@_-]/g, ''); 612}); 613$('#email').keyup(function() { 614 this.value = this.value.replace(/[^a-zA-Z0-9\.@_-]/g, ''); 615}); 616/* End Common Scripts */ 617 618/* Landing Page Scripts */ 619$('.other-explanation').hide(); 620$('#hearAboutUs').change(function() { 621 if ($(this).val() === 'Other') { 622 $('.other-explanation').show(); 623 } else { 624 $('.other-explanation').hide(); 625 } 626}); 627$('#rhearAboutUs').change(function() { 628 if ($(this).val() === 'Other') { 629 $('.other-explanation').show(); 630 } else { 631 $('.other-explanation').hide(); 632 } 633}); 634$('.location1city-other').hide(); 635$('#location1').change(function() { 636 if ($(this).val() === 'Other') { 637 $('.location1city-other').show(); 638 } else { 639 $('.location1city-other').hide(); 640 $('#location1OtherCity').val(''); 641 } 642}); 643$('.location2city-other').hide(); 644$('#location2').change(function() { 645 if ($(this).val() === 'Other') { 646 $('.location2city-other').show(); 647 } else { 648 $('.location2city-other').hide(); 649 $('#location2OtherCity').val(''); 650 } 651}); 652$('.location3city-other').hide(); 653$('#location3').change(function() { 654 if ($(this).val() === 'Other') { 655 $('.location3city-other').show(); 656 } else { 657 $('.location3city-other').hide(); 658 $('#location3OtherCity').val(''); 659 } 660}); 661 662 663/* End Landing Page Scripts */ 664 665/* FAQ Page Scripts */ 666$('.faqs dd').hide(); 667$('.faqs dt').click(function() { 668 $('.faqs dd').slideUp(); 669 $(this).next().slideToggle('normal'); 670}); 671/* End FAQ Page Scripts */ 672 673/* Apply Now Page Scripts */ 674$('.other-manage-center').hide(); 675$('#whoManageCenter').change(function() { 676 if ($(this).val() === 'Other') { 677 $('.other-manage-center').show(); 678 } else { 679 $('.other-manage-center').hide(); 680 } 681}); 682$('.other-hear-about-us').hide(); 683$('#hearAboutUs').change(function() { 684 if ($(this).val() === 'Other') { 685 $('.other-hear-about-us').show(); 686 } else if($(this).val() === 'Referral') { 687 $('.other-hear-about-us').show(); 688 } else { 689 $('.other-hear-about-us').hide(); 690 $('#hearAboutUsReferralName').val(''); 691 } 692}); 693$('.involvement-explain-field').hide(); 694$('#associationsCommunityKey').change(function() { 695 if ($(this).val() != '') { 696 $('.involvement-explain-field').show(); 697 } else { 698 $('.involvement-explain-field').hide(); 699 700 } 701}); 702 703function closeFormSessionAlert() { 704 var currentURL = window.location.href; 705 location.href = currentURL; 706} 707function closeErrorAlert() { 708 $('#loading').hide(); 709 $('#eMsg').html(''); 710 $('#failure').hide(); 711 $('.modal-backdrop').css({ 712 display : 'none' 713 }); 714 $('.main-container').removeClass('bfixed'); 715 $("body").removeClass("popup-added"); 716} 717 718function closeSuccessAlert() { 719 $('#loading').hide(); 720 $('#sMsg').html(''); 721 $('#success').hide(); 722 $('.modal-backdrop').css({ 723 display : 'none' 724 }); 725 $('.main-container').removeClass('bfixed'); 726} 727 728 729function closeLocationsAlert() { 730 $('#loading').hide(); 731 $('#state-locations').html(''); 732 $('#state-locations').hide(); 733 $('.modal-backdrop').css({ 734 display : 'none' 735 }); 736 $('.main-container').removeClass('bfixed'); 737 $("body").removeClass("popup-added"); 738} 739 740 741function showMoreLocationsForZipcode(){ 742 try{ 743 $( "form .error-block" ).removeClass("error-block"); 744 $( ".error-msg" ).addClass("hidden"); 745 $( ".form-control" ).siblings(".error-msg").text( "" ); 746 $('#loading').show(); 747 748 var zipcode = $("input[name='zipcode']").val().replace(/\s/g, ""); 749 if(zipcode == null || zipcode == "") { 750 var errMsg = ''; 751 errMsg += "<li>Please provide a valid zip/postal code.</li>"; 752 showError(errMsg); 753 $('#loading').hide(); 754 755 } else { 756 var country = null; 757 var searchLat = null, searchLong = null; 758 759 if (isCanadaPostalCode(zipcode)) { 760 zipcode = zipcode.slice(0,3) + ' ' + zipcode.slice(3); 761 country = 'CA'; 762 } 763 if (isUSPostalCode(zipcode)) { 764 country = 'US'; 765 } 766 if (isIndiaPostalCode(zipcode)) { 767 country = 'IN'; 768 } 769 if (isAustraliaPostCode(zipcode)) { 770 country = 'AU'; 771 } 772 773 if(country!=null) 774 { 775 var geocoder = new google.maps.Geocoder(); 776 geocoder.geocode({ 777 address : $.trim(zipcode) + ', ' + country 778 }, function(results, status) { 779 if (status == google.maps.GeocoderStatus.OK) { 780 mapcenter = results[0].geometry.location; 781 searchLat = results[0].geometry.location.lat(); 782 searchLong = results[0].geometry.location.lng(); 783 $('#loading').show(); 784 window.location.href = "locations-for-" + zipcode; 785 } else { 786 var errMsg = ''; 787 errMsg += "<li>Please provide a valid zip/postal code.</li>"; 788 showError(errMsg); 789 $('#loading').hide(); 790 } 791 }); 792 }else { 793 var errMsg = ''; 794 errMsg += "<li>Please provide a valid zip/postal code.</li>"; 795 showError(errMsg); 796 $('#loading').hide(); 797 } 798 window.location.href 799 } 800 } catch (e) { 801 alert(e); 802 } 803} 804 805 806function getStateLocations(countryId, stateId, stateName){ 807 try{ 808 $('#loading').show(); 809 $.ajax({
810 url : 'search-locations-by-state?countryId=' + countryId + '&stateId=' 811 + stateId + '&stateName=' + stateName, 812 context : document.body 813 }).done(function(data) { $('#loading').hide(); 814 $('#state-locations').html(data); 815 $('#state-locations').addClass('show-alert'); 816 }).fail(function(data) { 817 $('#loading').hide(); 818 showError(data); 819 }); 820 } catch (e) { 821 alert(e); 822 } 823} 824 825 826function validateZip(){ 827 try { 828 var zipcode = $('#zipcode').val(); var pageUrl = $('#pageUrl').val(); 829 if(zipcode == null || zipcode == "") { 830 var errMsg = ''; 831 errMsg ="<li>Please provide a valid zip/postal code.</li>"; 832 showError(errMsg); 833 return false; 834 } else { 835 var country = null; 836 837 if (isCanadaPostalCode($('#zipcode').val())) { 838 country = 'CA'; 839 } 840 if (isUSPostalCode($('#zipcode').val())) { 841 country = 'US'; 842 } 843 if (isIndiaPostalCode($('#zipcode').val())) { 844 country = 'IN'; 845 } 846 847 if(country!=null) 848 { 849 if(country == 'CA' && zipcode.length != 7){ 850 return false; 851 } 852 var geocoder = new google.maps.Geocoder(); 853 geocoder.geocode({ 854 address : $.trim(zipcode) + ', ' + country 855 }, function(results, status) { 856 if (status != google.maps.GeocoderStatus.OK) { 857 showError('<li>Please provide a valid zip/postal code.</li>'); 858 return false; 859 } 860 }); 861 } else { 862 if(zipcode.substr(5, 1) != '-'){ 863 showError('<li>Please provide a valid zip/postal code.</li>'); 864 return false; 865 } 866 } 867 } 868 } catch (e) { 869 alert(e); 870 } 871} 872 873function saveCareer() { 874 try { 875 $('#loading').fadeIn(); 876 $('.backend-errors').empty(); 877 878 html2canvas(document.getElementById("career-form-div"), { 879 useCORS: true, 880 scale: 2, 881 backgroundColor: null 882 }).then(function (canvas) { 883 const screenshotBase64 = canvas.toDataURL("image/png"); 884 885 // Submit screenshot to separate controller via AJAX 886 $.ajax({ 887 type: "POST", 888 url: "save-career-screenshot", 889 data: { 890 locationId: $('#locationId').val() || 0, 891 firstName: $('#firstName').val() || 'fn', 892 lastName: $('#lastName').val() || 'ln', 893 screenshotData: screenshotBase64 894 }, 895 success: function () { 896 console.log("Before submit screenshot saved with error."); 897 }, 898 error: function () { 899 console.error("Failed to save before submit screenshot."); 900 }, 901 complete: function () { 902 } 903 }); 904 }).catch(function (error) { 905 console.error("Before submit screenshot capture failed:", error); 906 }).finally(function () { 907 $( "form .error-block" ).removeClass("error-block"); 908 $( ".error-msg" ).addClass("hidden"); 909 $( ".form-control" ).siblings(".error-msg").text( "" ); 910 $( "#formCaptcha" ).siblings(".error-msg").text( "" ); 911 912 $(".location-selection-error").text( "" ); 913 914 var errMsg = ''; 915 /*var locality = trim($('#locality').val()); 916 var selectedAddress = trim($('#google-address').val());*/ 917 var firstName = trim($('#firstName').val()); 918 var lastName = trim($('#lastName').val()); 919 var emailId = trim($('#email').val()); 920 var phoneNo = trim($('#phone').val()); 921 var address = trim($('#address').val()); 922 var resume = trim($('#resume').val()); 923 var experienceInEducation = trim($('#experienceInEducation').val()); 924 var experienceWorkingWithChildren = trim($('#experienceWorkingWithChildren').val()); 925 var whyBestBrains = trim($('#whyBestBrains').val()); 926 var pageName = trim($('#pageName').val()); 927 var trace = trim($('#trace').val()); 928 var locationId = trim($('#locationId').val()); 929 var v = grecaptcha.getResponse(formCaptchaWidId); 930 var re = /(\.doc|\.docx|\.pdf)$/i; 931 932 /*if (locality == undefined || locality == 'undefined' || locality == '' || selectedAddress == '') { 933 $( "#locality" ).parent().addClass("error-block").children(".error-msg").text( "Please Type and Select address from dropdown." ); 934 errMsg += $( "#locality" ).siblings(".error-msg").text(); 935 }*/ 936 if ((locationId == undefined || locationId == '') && !window.bbNoLocationMode) { 937 $( "#locationId" ).parent().addClass("error-block").children(".error-msg").text( t("choose.a.location") ); 938 errMsg += $( "#locationId" ).siblings(".error-msg").text(); 939 } 940 if (firstName == undefined || firstName == '') { 941 $( "#firstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 942 errMsg += $( "#firstName" ).siblings(".error-msg").text(); 943 } 944 if (lastName == undefined || lastName == '') { 945 $( "#lastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 946 errMsg += $( "#lastName" ).siblings(".error-msg").text(); 947 } 948 if (emailId == undefined || emailId == '' || !checkemail(emailId)) { 949 $( "#email" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.email.address") ); 950 errMsg += $( "#email" ).siblings(".error-msg").text(); 951 } 952 if (phoneNo == undefined || phoneNo == '' || !checkphone(phoneNo)) { 953 $( "#phone" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.phone.number") ); 954 errMsg += $( "#phone" ).siblings(".error-msg").text(); 955 } 956 if (address == undefined || address == '') { 957 $( "#address" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 958 errMsg += $( "#address" ).siblings(".error-msg").text(); 959 } 960 if (resume == undefined || resume == '') { 961 $( "#resume" ).parent().addClass("error-block").children(".error-msg").text( t("upload.your.resume.cv") ); 962 errMsg += $( "#resume" ).siblings(".error-msg").text(); 963 } 964 if (resume != '' && resume != null) { 965 if (!re.exec(resume)) { 966 $( "#resume" ).parent().addClass("error-block").children(".error-msg").text( t("upload.your.resume.cv.format") ); 967 errMsg += $( "#resume" ).siblings(".error-msg").text(); 968 } 969 } 970 if (experienceInEducation == undefined || experienceInEducation == '') { 971 $( "#experienceInEducation" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 972 errMsg += $( "#experienceInEducation" ).siblings(".error-msg").text(); 973 } 974 if (experienceWorkingWithChildren == undefined || experienceWorkingWithChildren == '') { 975 $( "#experienceWorkingWithChildren" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 976 errMsg += $( "#experienceWorkingWithChildren" ).siblings(".error-msg").text(); 977 } 978 if (whyBestBrains == undefined || whyBestBrains == '') { 979 $( "#whyBestBrains" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 980 errMsg += $( "#whyBestBrains" ).siblings(".error-msg").text(); 981 } 982 if (pageName == undefined || pageName == '') { 983 $( "#pageName" ).parent().addClass("error-block").children(".error-msg").text( t("error.occuring.try.again") ); 984 errMsg += $( "#pageName" ).siblings(".error-msg").text(); 985 } 986 if (trace == undefined || trace == '') { 987 $( "#trace" ).parent().addClass("error-block").children(".error-msg").text( t("error.occuring.try.again") ); 988 errMsg += $( "#trace" ).siblings(".error-msg").text(); 989 } 990 if (v.length == 0) { 991 $( "#formCaptcha" ).parent().addClass("error-block").children(".error-msg").text( t("missed.captcha") ); 992 errMsg += $( "#formCaptcha" ).siblings(".error-msg").text(); 993 } 994 $('#gRecaptchaResponse').val(v); 995 if (errMsg != '') { 996 showInlineError(errMsg); 997 //$("html, body").animate({ scrollTop: 0 }); 998 $('html,body').animate({ scrollTop: $(".career-form-block").offset().top-90}, 'fast'); 999 grecaptcha.reset(formCaptchaWidId); 1000 setTimeout(function () { 1001 html2canvas(document.getElementById("career-form-div"), { 1002 useCORS: true, 1003 scale: 2, 1004 backgroundColor: null 1005 }).then(function (canvas) { 1006 const screenshotBase64 = canvas.toDataURL("image/png"); 1007 1008 // Step 3: Send screenshot to backend 1009 $.ajax({
1010 type: "POST", 1011 url: "save-career-screenshot", 1012 data: { 1013 locationId: locationId || 0, 1014 firstName: $('#firstName').val() || 'fn', 1015 lastName: $('#lastName').val() || 'ln', 1016 screenshotData: screenshotBase64 1017 }, 1018 success: function () { 1019 console.log("After submit screenshot with errors saved."); 1020 }, 1021 error: function () { 1022 console.error("Failed to save after submit screenshot."); 1023 }, 1024 complete: function () { 1025 $('#loading').fadeOut(500); 1026 } 1027 }); 1028 }).catch(function (error) { 1029 console.error("After submit screenshot capture failed:", error); 1030 $('#loading').fadeOut(500); 1031 }); 1032 }, 100); // slight delay ensures inline errors are rendered in DOM 1033 } else { 1034 $('#loading').show(); 1035 document.careerForm.submit(); 1036 grecaptcha.reset(formCaptchaWidId); 1037 /*html2canvas(document.getElementById("career-form-div"), { 1038 useCORS: true, 1039 scale: 2, 1040 backgroundColor: null 1041 }).then(function (canvas) { 1042 const screenshotBase64 = canvas.toDataURL("image/png"); 1043 $('#screenshotData').val(screenshotBase64); 1044 $('#loading').show(); 1045 document.careerForm.submit(); 1046 grecaptcha.reset(formCaptchaWidId); 1047 }).catch(function (error) { 1048 console.error("Screenshot capture failed:", error); 1049 showInlineError("Something went wrong. Please try again!"); 1050 $("html, body").animate({ scrollTop: 0 }); 1051 $('#loading').fadeOut(500); 1052 grecaptcha.reset(formCaptchaWidId); 1053 });*/ 1054 } 1055 }); 1056 } catch (e) { alert(e); 1057 return false; 1058 } 1059} 1060 1061function saveCareerScreenshot() { 1062 $('#loading').fadeIn(); 1063 1064 return new Promise((resolve, reject) => { 1065 try { 1066 var locationId = trim($('#locationId').val()); 1067 1068 html2canvas(document.getElementById("career-form-div"), { 1069 useCORS: true, 1070 scale: 2, 1071 backgroundColor: null 1072 }).then(function (canvas) { 1073 const screenshotBase64 = canvas.toDataURL("image/png"); 1074 1075 // Submit screenshot to separate controller via AJAX 1076 $.ajax({
1077 type: "POST", 1078 url: "save-career-screenshot", 1079 data: { 1080 locationId: locationId || 0, 1081 firstName: $('#firstName').val() || 'fn', 1082 lastName: $('#lastName').val() || 'ln', 1083 screenshotData: screenshotBase64 1084 }, 1085 success: function () { 1086 console.log("Backend errors screenshot saved with error."); 1087 resolve(); // Resolve the promise when AJAX is done 1088 }, 1089 error: function () { 1090 console.error("Failed to save backend errors screenshot."); 1091 resolve(); // Resolve the promise when AJAX is done 1092 }, 1093 complete: function () { 1094 $('#loading').fadeOut(500); 1095 } 1096 }); 1097 }).catch(function (error) { 1098 console.error("Backend errors screenshot capture failed:", error); 1099 resolve(); // Resolve the promise when AJAX is done 1100 $('#loading').fadeOut(500); 1101 }); 1102 } catch (e) { 1103 console.error(e); 1104 $('#loading').fadeOut(500); 1105 resolve(); // Resolve the promise when AJAX is done 1106 } 1107 }); 1108} 1109 1110function saveCareerEndScreenshot() { 1111 $('#loading').fadeIn(); 1112 try { 1113 var locationId = trim($('#locationId').val()); 1114 var status = $('#screenshot-div').data('value'); 1115 1116 html2canvas(document.getElementById("screenshot-div"), { 1117 useCORS: true, 1118 scale: 2, 1119 backgroundColor: null 1120 }).then(function (canvas) { 1121 const screenshotBase64 = canvas.toDataURL("image/png"); 1122 1123 // Submit screenshot to separate controller via AJAX 1124 $.ajax({ 1125 type: "POST", 1126 url: "save-career-screenshot", 1127 data: { 1128 locationId: locationId || 0, 1129 firstName: $('#firstName').val() || 'fn', 1130 lastName: ($('#lastName').val() || 'ln') + status, 1131 screenshotData: screenshotBase64 1132 }, 1133 success: function () { 1134 console.log("Career end screenshot saved with error."); 1135 }, 1136 error: function () { 1137 console.error("Failed to save career end screenshot."); 1138 }, 1139 complete: function () { 1140 $('#loading').fadeOut(500); 1141 } 1142 }); 1143 }).catch(function (error) { 1144 console.error("Career end screenshot capture failed:", error); 1145 $('#loading').fadeOut(500); 1146 }); 1147 } catch (e) { 1148 console.error(e); 1149 $('#loading').fadeOut(500); 1150 } 1151} 1152 1153 1154function saveRegistrationParentInfo() { 1155 try { 1156 1157 1158 $( "form .error-block" ).removeClass("error-block"); 1159 $( "#formCaptcha" ).siblings(".error-msg").text( "" ); 1160 $( ".error-msg" ).addClass("hidden"); 1161 $( ".form-control" ).siblings(".error-msg").text( "" ); 1162 $( ".form-control" ).parent(".zipcode-input-group").siblings(".error-msg").text( "" ); 1163 $(".location-selection-error").text( "" ); 1164 1165 $('#loading').fadeIn(); 1166 1167 1168 var errMsg = ''; 1169 1170 1171 var firstName = trim($('#firstName').val()); var lastName = trim($('#lastName').val()); 1172 var phone = trim($('#phone').val()); var email = trim($('#email').val()); 1173 var zipcode = trim($('#zipcode').val()); var locationId = trim($('#locationId').val()); 1174 var noOfChildren = trim($('#noOfChildren').val()); var hearAboutUs = trim($('#hearAboutUs').val()); 1175 var referralName = trim($('#referralName').val()); var otherExpl = trim($('#otherExpl').val()); 1176 var v = grecaptcha.getResponse(formCaptchaWidId); 1177 1178 1179 1180 1181 1182 if (firstName == undefined || firstName == 'undefined' || firstName == '') { 1183 $( "#firstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1184 errMsg += $( "#firstName" ).siblings(".error-msg").text(); 1185 } 1186 if (lastName == undefined || lastName == 'undefined' || lastName == '') { 1187 $( "#lastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1188 errMsg += $( "#lastName" ).siblings(".error-msg").text(); 1189 } 1190 if (phone == undefined || phone == 'undefined' || phone == '' || !checkphone(phone)) { 1191 $( "#phone" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.phone.number") ); 1192 errMsg += $( "#phone" ).siblings(".error-msg").text(); 1193 } 1194 if (email == undefined || email == 'undefined' || email == '' || !checkemail(email)) { 1195 $( "#email" ).parent().addClass("error-block").children(".error-msg").text( t("enter.valid.email.address") ); 1196 errMsg += $( "#email" ).siblings(".error-msg").text(); 1197 } 1198 if (zipcode == undefined || zipcode == 'undefined' || zipcode == '') { 1199 $( "#zipcode" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1200 errMsg += $( "#zipcode" ).siblings(".error-msg").text(); 1201 } 1202 if (locationId == undefined || locationId == 'undefined' || locationId == '') { 1203 $( "#locationId" ).parent().addClass("error-block").children(".error-msg").text( t("choose.a.location") ); 1204 errMsg += $( "#locationId" ).siblings(".error-msg").text(); 1205 } 1206 if (noOfChildren == undefined || noOfChildren == 'undefined' || noOfChildren == '') { 1207 $( "#noOfChildren" ).parent().addClass("error-block").children(".error-msg").text( t("must.select.atleast.one.student") ); 1208 errMsg += $( "#noOfChildren" ).siblings(".error-msg").text(); 1209 1210 } 1211 if (hearAboutUs == undefined || hearAboutUs == 'undefined' || hearAboutUs == '') { 1212 $( "#hearAboutUs" ).parent().addClass("error-block").children(".error-msg").text( t("select.an.option") ); 1213 errMsg += $( "#hearAboutUs" ).siblings(".error-msg").text(); 1214 } 1215 if(hearAboutUs != '' && hearAboutUs == 'Referral'){ 1216 if(referralName == undefined || referralName == 'undefined' || referralName == ''){ 1217 $( "#referralName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1218 errMsg += $( "#referralName" ).siblings(".error-msg").text(); 1219 } 1220 } 1221 if(hearAboutUs != '' && hearAboutUs == 'Other'){ 1222 if(otherExpl == undefined || otherExpl == 'undefined' || otherExpl == ''){ 1223 $( "#otherExpl" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1224 errMsg += $( "#otherExpl" ).siblings(".error-msg").text(); 1225 } 1226 } 1227 if (v.length == 0) { 1228 $( "#formCaptcha" ).parent().addClass("error-block").children(".error-msg").text( t("missed.captcha") ); 1229 errMsg += $( "#formCaptcha" ).siblings(".error-msg").text(); 1230 } 1231 if($('#receivePromotionalMails').is(':checked')){ 1232 $('#receivePromotionalMails').val(true); 1233 } else{ 1234 $('#receivePromotionalMails').val(''); 1235 } 1236 $('#gRecaptchaResponse').val(v); 1237 if (errMsg != '') { 1238 showInlineError(errMsg); 1239 $("html, body").animate({ scrollTop: 0 }); 1240 $('#loading').fadeOut(500); 1241 grecaptcha.reset(formCaptchaWidId); 1242 return false; 1243 } else { 1244 $('#loading').show(); 1245 document.saveRegParentInfoForm.submit(); 1246 grecaptcha.reset(formCaptchaWidId); 1247 } 1248 } catch (e) { 1249 alert(e); 1250 } 1251} 1252 1253function getAge(dob) { 1254 var fmt = dob.split("-"); var age = ''; 1255 if(fmt.length == 3) { 1256 var mm = fmt[0]-1, dd = fmt[1], yy = fmt[2]; 1257 1258 var today = new Date(); 1259 var birthDate = new Date(yy,mm,dd); 1260 age = today.getFullYear() - birthDate.getFullYear(); 1261 var m = today.getMonth() - birthDate.getMonth(); 1262 if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { 1263 age--; 1264 } 1265 } 1266 return age; 1267} 1268 1269function getPackageDropDownByDob(month, date, year, id, stdAge, dobLabel) { 1270 try{ 1271 var errMsg = ''; var locationId = trim($('#locationId').val()); 1272 var monthLength = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; 1273 if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) 1274 monthLength[1] = 29; 1275 if(monthLength[month-1] < date) 1276 errMsg += '<li>' + t("enter.valid.date") + '</li>'; 1277 if(locationId == undefined || locationId == 'undefined' || locationId == ''){ 1278 errMsg += '<li>
1278' + t("location.id.not.found") + '</li>'; 1279 } 1280 if(month == undefined || month == 'undefined' || month == ''){ 1281 errMsg += '<li>' + t("select.month.of.dob") + '</li>'; 1282 } 1283 if(date == undefined || date == 'undefined' || date == ''){ 1284 errMsg += '<li>' + t("select.day.of.dob") + '</li>'; 1285 } 1286 if(year == undefined || year == 'undefined' || year == ''){ 1287 errMsg += '<li>' + t("select.year.of.dob") + '</li>'; 1288 } 1289 1290 if(month != '' && date != '' && year != ''){ 1291 var dob = month + '-' + (date < 10 ? "0" : "") + date + '-' + year; 1292 $('#'+dobLabel).val(dob); 1293 1294 var age = getAge(dob); 1295 if(age == undefined || age == 'undefined' || age == ''){ 1296 errMsg += '<li>' + t("invalid.age") + '</li>'; 1297 } 1298 if(age != '' && age < 3){ 1299 errMsg += '<li>' + t("child.must.be.atleast.three.years.old") + '<li>'; 1300 } else{ 1301 $('#'+stdAge).val(age); 1302 } 1303 } 1304 if (errMsg != '') { 1305 showPackageError(errMsg); 1306 return false; 1307 } else { 1308 $('#loading').show(); 1309 $.ajax({ 1310 url : 'get-location-packages-by-dob?locationId=' + locationId + '&dateOfBirth=' + dob 1311 + '&token=' + ($('#registrationToken').val() || ''), 1312 context : document.body 1313 }).done(function(data) { $('#loading').hide(); 1314 $('#'+id).html(data); 1315 }).fail(function(data) {$('#loading').hide(); 1316 showPackageError(data); 1317 }); 1318 } 1319 } catch (e) { 1320 alert(e); 1321 } 1322} 1323 1324function getSubjectsByPackage(locationPackageId, label, id, stdAge) { 1325 try{ 1326 var locationId = trim($('#locationId').val()); 1327 var age = trim($('#'+stdAge).val()); 1328 1329 $('#loading').show(); 1330 $('#h-'+label).val(''); 1331 $('#'+label+'-noOfSelectedOpt').val(''); 1332 $.ajax({ 1333 url : 'get-subjects-by-location-package?locationId=' + locationId + '&locationPackageId=' + locationPackageId 1334 + '&label=' + label + '&age=' + age + '&token=' + ($('#registrationToken').val() || ''), context : document.body 1335 }).done(function(data) { $('#loading').hide(); 1336 $('#'+id).html(data); 1337 }).fail(function(data) { $('#loading').hide(); 1338 showError(data); 1339 }); 1340 } catch (e) { 1341 alert(e); 1342 } 1343} 1344 1345function getSubjectIdsOnClick(subjectId, noOfOpt, id) { 1346 try{ 1347 var regSubjIds = []; 1348 $.each($("input[name='"+ id +"']:checked"), 1349 function() { 1350 regSubjIds.push($(this).val()); 1351 }); 1352 $('#h-'+id).val(regSubjIds); 1353 $('#'+id+'-noOfSelectedOpt').val(noOfOpt); 1354 } catch (e) { 1355 alert(e); 1356 } 1357} 1358 1359function goBackTo(){ 1360 try{ 1361 // Carry the token so returning to the parent form rebuilds the registration after a session timeout. 1362 // (Which parent form â generic vs location â is persisted server-side on the registration itself.) 1363 window.location.href = "new-registration-back?token=" + ($('#registrationToken').val() || ''); 1364 } catch(e){ 1365 alert(e); 1366 } 1367} 1368 1369function saveStudentRegistration() { 1370 try { 1371 $( "form .error-block" ).removeClass("error-block"); 1372 $( ".error-msg" ).addClass("hidden").text( "" ); 1373 1374 $('#loading').fadeIn(); 1375 var errMsg = ''; 1376 var locationId = trim($('#locationId').val()); 1377 var parentId = trim($('#parentId').val()); 1378 var noOfChildren = trim($('#noOfChildren').val()); 1379 1380 // Populate each hidden DateOfBirth from its month/date/year selects so a filled DOB validates even 1381 // when the user never triggered "Get Packages" (which was previously the only place it was set). 1382 for (var si = 1; si <= 6; si++) { 1383 var m = $('#s' + si + 'Month').val(); 1384 var d = $('#s' + si + 'Date').val(); 1385 var y = $('#s' + si + 'Year').val(); 1386 if (m && d && y && m != '' && d != '' && y != '') { 1387 $('#s' + si + 'DateOfBirth').val(m + '-' + (d < 10 ? '0' : '') + d + '-' + y); 1388 } 1389 } 1390 1391 var s1FirstName = trim($('#s1FirstName').val()); 1392 var s1LastName = trim($('#s1LastName').val()); 1393 var s1Gender = trim($('#s1Gender').val()); 1394 var s1DateOfBirth = trim($('#s1DateOfBirth').val()); 1395 var s1LocationPackageId = trim($('#s1LocationPackageId').val()); 1396 var s1subjects = trim($('#h-s1subjects').val()); 1397 var s1SubjIds = []; 1398 1399 var s2FirstName = trim($('#s2FirstName').val()); 1400 var s2LastName = trim($('#s2LastName').val()); 1401 var s2Gender = trim($('#s2Gender').val()); 1402 var s2DateOfBirth = trim($('#s2DateOfBirth').val()); 1403 var s2LocationPackageId = trim($('#s2LocationPackageId').val()); 1404 var s2subjects = trim($('#h-s2subjects').val()); 1405 var s2SubjIds = []; 1406 1407 var s3FirstName = trim($('#s3FirstName').val()); 1408 var s3LastName = trim($('#s3LastName').val()); 1409 var s3Gender = trim($('#s3Gender').val()); 1410 var s3DateOfBirth = trim($('#s3DateOfBirth').val()); 1411 var s3LocationPackageId = trim($('#s3LocationPackageId').val()); 1412 var s3subjects = trim($('#h-s3subjects').val()); 1413 var s3SubjIds = []; 1414 1415 var s4FirstName = trim($('#s4FirstName').val()); 1416 var s4LastName = trim($('#s4LastName').val()); 1417 var s4Gender = trim($('#s4Gender').val()); 1418 var s4DateOfBirth = trim($('#s4DateOfBirth').val()); 1419 var s4LocationPackageId = trim($('#s4LocationPackageId').val()); 1420 var s4subjects = trim($('#h-s4subjects').val()); 1421 var s4SubjIds = []; 1422 1423 var s5FirstName = trim($('#s5FirstName').val()); 1424 var s5LastName = trim($('#s5LastName').val()); 1425 var s5Gender = trim($('#s5Gender').val()); 1426 var s5DateOfBirth = trim($('#s5DateOfBirth').val()); 1427 var s5LocationPackageId = trim($('#s5LocationPackageId').val()); 1428 var s5subjects = trim($('#h-s5subjects').val()); 1429 var s5SubjIds = []; 1430 1431 var s6FirstName = trim($('#s6FirstName').val()); 1432 var s6LastName = trim($('#s6LastName').val()); 1433 var s6Gender = trim($('#s6Gender').val()); 1434 var s6DateOfBirth = trim($('#s6DateOfBirth').val()); 1435 var s6LocationPackageId = trim($('#s6LocationPackageId').val()); 1436 var s6subjects = trim($('#h-s6subjects').val()); 1437 var s6SubjIds = []; 1438 1439 if (locationId == undefined || locationId == 'undefined' || locationId == '') { 1440 $( "#locationId" ).parent().addClass("error-block").children(".error-msg").text( t("location.not.foun
1440d.try.again") ); 1441 errMsg += $( "#locationId" ).siblings(".error-msg").text(); 1442 1443 } 1444 if (parentId == undefined || parentId == 'undefined' || parentId == '') { 1445 $( "#parentId" ).parent().addClass("error-block").children(".error-msg").text( t("parent.details.not.provided.try.again") ); 1446 errMsg += $( "#parentId" ).siblings(".error-msg").text(); 1447 1448 } 1449 1450 if (noOfChildren == 1 || noOfChildren == 2 || noOfChildren == 3 || noOfChildren == 4 || noOfChildren == 5 || noOfChildren == 6) { 1451 if (s1FirstName == undefined || s1FirstName == '') { 1452 $( "#s1FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1453 errMsg += $( "#s1FirstName" ).siblings(".error-msg").text(); 1454 1455 } 1456 if (s1LastName == undefined || s1LastName == '') { 1457 $( "#s1LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1458 errMsg += $( "#s1LastName" ).siblings(".error-msg").text(); 1459 1460 } 1461 if (s1DateOfBirth == undefined || s1DateOfBirth == '') { 1462 $( "#s1DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1463 errMsg += $( "#s1DateOfBirth" ).siblings(".error-msg").text(); 1464 1465 } 1466 if (s1LocationPackageId == undefined || s1LocationPackageId == '') { 1467 $( "#s1LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1468 errMsg += $( "#s1LocationPackageId" ).siblings(".error-msg").text(); 1469 1470 } 1471 1472 if(s1subjects == undefined || s1subjects == ''){ 1473 var regSubjIds = []; 1474 $.each($("input[name='s1subjects']:checked"), 1475 function() { 1476 regSubjIds.push($(this).val()); 1477 }); 1478 $('#h-s1subjects').val(regSubjIds); 1479 s1subjects = trim($('#h-s1subjects').val()); 1480 var s1Subjs = s1subjects.split(','); 1481 $('#s1subjects-noOfSelectedOpt').val(s1Subjs.length); 1482 } 1483 1484 if(s1LocationPackageId != ''){ 1485 if (s1subjects == undefined || s1subjects == '') { 1486 $( "#h-s1subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1487 errMsg += $( "#h-s1subjects" ).siblings(".error-msg").text(); 1488 1489 } else { 1490 s1SubjIds = s1subjects.split(','); 1491 } 1492 if (s1SubjIds != '' && s1SubjIds.length != (parseInt($('#s1subjects-noOfSelectedOpt').val())) && s1subjects != '' && s1subjects != undefined) { 1493 $( "#h-s1subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s1subjects-noOfSelectedOpt').val()]) ); 1494 errMsg += $( "#h-s1subjects" ).siblings(".error-msg").text(); 1495 1496 // errMsg += '<li>You must select ' + $('#s1subjects-noOfSelectedOpt').val() + ' Subjects in the Package for Student 1 !!\n</li>'; 1497 } 1498 } 1499 } 1500 if (noOfChildren == 2 || noOfChildren == 3 || noOfChildren == 4 || noOfChildren == 5 || noOfChildren == 6) { 1501 if (s2FirstName == undefined || s2FirstName == '') { 1502 $( "#s2FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1503 errMsg += $( "#s2FirstName" ).siblings(".error-msg").text(); 1504 1505 } 1506 if (s2LastName == undefined || s2LastName == '') { 1507 $( "#s2LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1508 errMsg += $( "#s2LastName" ).siblings(".error-msg").text(); 1509 1510 } 1511 if (s2DateOfBirth == undefined || s2DateOfBirth == '') { 1512 $( "#s2DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1513 errMsg += $( "#s2DateOfBirth" ).siblings(".error-msg").text(); 1514 1515 } 1516 if (s2LocationPackageId == undefined || s2LocationPackageId == '') { 1517 $( "#s2LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1518 errMsg += $( "#s2LocationPackageId" ).siblings(".error-msg").text(); 1519 1520 } 1521 1522 if(s2subjects == undefined || s2subjects == ''){ 1523 var regSubjIds = []; 1524 $.each($("input[name='s2subjects']:checked"), 1525 function() { 1526 regSubjIds.push($(this).val()); 1527 }); 1528 $('#h-s2subjects').val(regSubjIds); 1529 s2subjects = trim($('#h-s2subjects').val()); 1530 var s2Subjs = s2subjects.split(','); 1531 $('#s2subjects-noOfSelectedOpt').val(s2Subjs.length); 1532 } 1533 1534 if(s2LocationPackageId != ''){ 1535 if (s2subjects == undefined || s2subjects == '') { 1536 $( "#s2LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1537 errMsg += $( "#s2LocationPackageId" ).siblings(".error-msg").text(); 1538 1539 1540 } else { 1541 s2SubjIds = s2subjects.split(','); 1542 } 1543 if (s2SubjIds != '' && s2SubjIds.length != (parseInt($('#s2subjects-noOfSelectedOpt').val())) && s2subjects != '' && s2subjects != undefined) { 1544 $( "#h-s2subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s2subjects-noOfSelectedOpt').val()]) ); 1545 errMsg += $( "#h-s2subjects" ).siblings(".error-msg").text(); 1546 } 1547 } 1548 } 1549 if (noOfChildren == 3 || noOfChildren == 4 || noOfChildren == 5 || noOfChildren == 6) { 1550 if (s3FirstName == undefined || s3FirstName == '') { 1551 $( "#s3FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1552 errMsg += $( "#s3FirstName" ).siblings(".error-msg").text(); 1553 1554 } 1555 if (s3LastName == undefined || s3LastName == '') {
1556 $( "#s3LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1557 errMsg += $( "#s3LastName" ).siblings(".error-msg").text(); 1558 1559 } 1560 if (s3DateOfBirth == undefined || s3DateOfBirth == '') { 1561 $( "#s3DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1562 errMsg += $( "#s3DateOfBirth" ).siblings(".error-msg").text(); 1563 1564 } 1565 if (s3LocationPackageId == undefined || s3LocationPackageId == '') { 1566 $( "#s3LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1567 errMsg += $( "#s3LocationPackageId" ).siblings(".error-msg").text(); 1568 1569 } 1570 1571 if(s3subjects == undefined || s3subjects == ''){ 1572 var regSubjIds = []; 1573 $.each($("input[name='s3subjects']:checked"), 1574 function() { 1575 regSubjIds.push($(this).val()); 1576 }); 1577 $('#h-s3subjects').val(regSubjIds); 1578 s3subjects = trim($('#h-s3subjects').val()); 1579 var s3Subjs = s3subjects.split(','); 1580 $('#s3subjects-noOfSelectedOpt').val(s3Subjs.length); 1581 } 1582 1583 if(s3LocationPackageId != ''){ 1584 if (s3subjects == undefined || s3subjects == '') { 1585 $( "#s3subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1586 errMsg += $( "#s3subjects" ).siblings(".error-msg").text(); 1587 1588 } else { 1589 s3SubjIds = s3subjects.split(','); 1590 } 1591 if (s3SubjIds != '' && s3SubjIds.length != (parseInt($('#s3subjects-noOfSelectedOpt').val())) && s3subjects != '' && s3subjects != undefined) { 1592 $( "#h-s3subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s3subjects-noOfSelectedOpt').val()]) ); 1593 errMsg += $( "#h-s3subjects" ).siblings(".error-msg").text(); 1594 1595 } 1596 } 1597 } 1598 if (noOfChildren == 4 || noOfChildren == 5 || noOfChildren == 6) { 1599 if (s4FirstName == undefined || s4FirstName == '') { 1600 $( "#s4FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1601 errMsg += $( "#s4FirstName" ).siblings(".error-msg").text(); 1602 1603 } 1604 if (s4LastName == undefined || s4LastName == '') { 1605 $( "#s4LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1606 errMsg += $( "#s4LastName" ).siblings(".error-msg").text(); 1607 1608 } 1609 if (s4DateOfBirth == undefined || s4DateOfBirth == '') { 1610 $( "#s4DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1611 errMsg += $( "#s4DateOfBirth" ).siblings(".error-msg").text(); 1612 1613 } 1614 if (s4LocationPackageId == undefined || s4LocationPackageId == '') { 1615 $( "#s4LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1616 errMsg += $( "#s4LocationPackageId" ).siblings(".error-msg").text(); 1617 1618 } 1619 1620 if(s4subjects == undefined || s4subjects == ''){ 1621 var regSubjIds = []; 1622 $.each($("input[name='s4subjects']:checked"), 1623 function() { 1624 regSubjIds.push($(this).val()); 1625 }); 1626 $('#h-s4subjects').val(regSubjIds); 1627 s4subjects = trim($('#h-s4subjects').val()); 1628 var s4Subjs = s4subjects.split(','); 1629 $('#s4subjects-noOfSelectedOpt').val(s4Subjs.length); 1630 } 1631 1632 if(s4LocationPackageId != ''){ 1633 if (s4subjects == undefined || s4subjects == '') { 1634 $( "#s4subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1635 errMsg += $( "#s4subjects" ).siblings(".error-msg").text(); 1636 1637 } else { 1638 s4SubjIds = s4subjects.split(','); 1639 } 1640 if (s4SubjIds != '' && s4SubjIds.length != (parseInt($('#s4subjects-noOfSelectedOpt').val())) && s4subjects != '' && s4subjects != undefined) { 1641 $( "#h-s4subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s4subjects-noOfSelectedOpt').val()]) ); 1642 errMsg += $( "#h-s4subjects" ).siblings(".error-msg").text(); 1643 } 1644 } 1645 } 1646 if (noOfChildren == 5 || noOfChildren == 6) { 1647 if (s5FirstName == undefined || s5FirstName == '') { 1648 $( "#s5FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1649 errMsg += $( "#s5FirstName" ).siblings(".error-msg").text(); 1650 1651 } 1652 if (s5LastName == undefined || s5LastName == '') { 1653 $( "#s5LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1654 errMsg += $( "#s5LastName" ).siblings(".error-msg").text(); 1655 1656 } 1657 if (s5DateOfBirth == undefined || s5DateOfBirth == '') { 1658 $( "#s5DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1659 errMsg += $( "#s5DateOfBirth" ).siblings(".error-msg").text(); 1660 1661 } 1662 if (s5LocationPackageId == undefined || s5LocationPackageId == '') { 1663 $( "#s5LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1664 errMsg += $( "#s5LocationPackageId" ).siblings(".error-msg").text(); 1665 1666 } 1667 1668 if(s5subjects == undefined || s5subjects == ''){ 1669 var regSubjIds = []; 1670 $.each($("input[name='s5subjects']:checked"), 1671 function() { 1672 regSubjIds.push($(this).val()); 1673 }); 1674 $('#h-s5subjects').val(regSubjIds); 1675 s5subjects = trim($('#h-s5subjects').val()); 1676 var s5Subjs = s5subjects.split(','); 1677 $('#s5subjects-noOfSelectedOpt').val(s5Subjs.length); 1678 } 1679 1680 if(s5LocationPackageId != ''){ 1681 if (s5subjects == undefined || s5subjects == '') { 1682 $( "#s5subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1683 errMsg += $( "#s5subjects" ).siblings(".error-msg").text(); 1684 1685 } else { 1686 s5SubjIds = s5subjects.split(','); 1687 } 1688 if (s5SubjIds != '' && s5SubjIds.length != (parseInt($('#s5subjects-noOfSelectedOpt').val())) && s5subjects != '' && s5subjects != undefined) { 1689 $( "#h-s5subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s5subjects-noOfSelectedOpt').val()]) ); 1690 errMsg += $( "#h-s5subjects" ).siblings(".error-msg").text(); 1691 } 1692 } 1693 } 1694 if (noOfChildren == 6) { 1695 if (s6FirstName == undefined || s6FirstName == '') { 1696 $( "#s6FirstName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1697 errMsg += $( "#s6FirstName" ).siblings(".error-msg").text(); 1698 1699 } 1700 if (s6LastName == undefined || s6LastName == '') { 1701 $( "#s6LastName" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1702 errMsg += $( "#s6LastName" ).siblings(".error-msg").text(); 1703 1704 } 1705 if (s6DateOfBirth == undefined || s6DateOfBirth == '') { 1706 $( "#s6DateOfBirth" ).parent().addClass("error-block").children(".error-msg").text( t("field.cannot.be.blank") ); 1707 errMsg += $( "#s6DateOfBirth" ).siblings(".error-msg").text(); 1708 1709 } 1710 if (s6LocationPackageId == undefined || s6LocationPackageId == '') { 1711 $( "#s6LocationPackageId" ).parent().addClass("error-block").children(".error-msg").text( t("select.package.option") ); 1712 errMsg += $( "#s6LocationPackageId" ).siblings(".error-msg").text(); 1713 1714 } 1715 1716 if(s6subjects == undefined || s6subjects == ''){ 1717 var regSubjIds = []; 1718 $.each($("input[name='s6subjects']:checked"), 1719 function() { 1720 regSubjIds.push($(this).val()); 1721 }); 1722 $('#h-s6subjects').val(regSubjIds); 1723 s6subjects = trim($('#h-s6subjects').val()); 1724 var s6Subjs = s6subjects.split(','); 1725 $('#s6subjects-noOfSelectedOpt').val(s6Subjs.length); 1726 } 1727 1728 if(s6LocationPackageId != ''){ 1729 if (s6subjects == undefined || s6subjects == '') { 1730 $( "#s6subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.a.subject") ); 1731 errMsg += $( "#s6subjects" ).siblings(".error-msg").text(); 1732 1733 } else { 1734 s6SubjIds = s6subjects.split(','); 1735 } 1736 if (s6SubjIds != '' && s6SubjIds.length != (parseInt($('#s6subjects-noOfSelectedOpt').val())) && s6subjects != '' && s6subjects != undefined) { 1737 $( "#h-s6subjects" ).parent().addClass("error-block").children(".error-msg").text( t("please.choose.no.subjects", [$('#s6subjects-noOfSelectedOpt').val()]) ); 1738 errMsg += $( "#h-s6subjects" ).siblings(".error-msg").text(); 1739 } 1740 } 1741 } 1742 if (errMsg != '') { 1743 showInlineError(errMsg); 1744 $("html, body").animate({ scrollTop: 0 }); 1745 $('#loading').fadeOut(500); 1746 } else { 1747 $('#loading').show(); 1748 $('#saveRegistrationStudentInfo').submit(); 1749 } 1750 } catch (e) { 1751 alert(e); 1752 return false; 1753 } 1754} 1755 1756function choosePaymentMode() { 1757 try { 1758 var errMsg = ''; 1759 var paymentMode = $("input:radio[name='paymentMode']:checked").val(); 1760 if (paymentMode == undefined || paymentMode == 'undefined' 1761 || paymentMode == '') { 1762 errMsg += '<li>' + t("choose.a.payment.method") + '</li>'; 1763 } 1764 if (errMsg != '') { 1765 showError(errMsg); 1766 return false; 1767 } else { 1768 if ($("#creditPayment").is(":checked")) { 1769 window.location.href = 'new-registration-credit-payment'; 1770 } 1771 if ($("#achPayment").is(":checked")) { 1772 window.location.href = 'new-registration-ach-payment'; 1773 } 1774 if ($("#payPalPayment").is(":checked")) { 1775 // Carry the pay-now origin so the PayPal page's Back returns to /registration-pay-now- rather 1776 // than the wizard summary (Build 3 issue 2). It rides the URL, so it survives a session timeout. 1777 var payNowFlag = ($('#payNowOrigin').val() === 'true') ? '&payNow=1' : ''; 1778 window.location.href = 'new-registration-paypal-payment?token='
1778+ ($('#registrationToken').val() || '') + payNowFlag; 1779 } 1780 if ($("#indiaPayment").is(":checked")) { 1781 // TODO: India online payment is not yet implemented server-side â there is no 1782 // new-registration-india-payment handler, so this route currently 404s. The token is threaded 1783 // here so the link is already capability-token-aware (matching the PayPal flow) once the India 1784 // gateway is built; until then, India locations should use "Save & Pay later". 1785 window.location.href = 'new-registration-india-payment?token=' + ($('#registrationToken').val() || ''); 1786 } 1787 } 1788 } catch (e) { 1789 alert(e); 1790 } 1791} 1792 1793 1794function goBackToStudentsPage(){ 1795 try{ 1796 // Carry the token so Back rebuilds the registration from the DB after a session timeout. 1797 window.location.href = "new-registration-students-back?token=" + ($('#registrationToken').val() || ''); 1798 } catch(e){ 1799 alert(e); 1800 } 1801} 1802 1803function saveAndPayLater() { 1804 try { 1805 var locationUrl = $('#locationUrl').val(); 1806 $('#loading').show(); 1807 // Carry the registration token so the confirmation rebuilds the session after a timeout. 1808 window.location.href = locationUrl + '/new-registration-save-and-pay-later?token=' + ($('#registrationToken').val() || ''); 1809 } catch (e) { 1810 alert(e); 1811 } 1812} 1813 1814function applyCouponCode() { 1815 try { 1816 var errMsg = ''; 1817 var couponCode = trim($('#couponCode').val()); 1818 if (couponCode == undefined || couponCode == 'undefined' || couponCode == '') { 1819 errMsg += '<li>' + t("enter.valid.coupon.code") + '</li>'; 1820 } 1821 if (errMsg != '') { 1822 showError(errMsg); 1823 return false; 1824 } else { 1825 $('#loading').show(); 1826 // Carry the pay-now origin so the rebuilt coupon fragment renders only "Check Out" (not the wizard's 1827 // Back / Save & Pay Later) after a session timeout on the email pay-now page. 1828 var payNowFlag = ($('#payNowOrigin').val() === 'true') ? '&payNow=1' : ''; 1829 $.ajax({ 1830 url : 'registration-apply-coupon?couponCode=' + couponCode + '&token=' + ($('#registrationToken').val() || '') + payNowFlag, 1831 context : document.body 1832 }).done(function(data) { $('#loading').hide(); 1833 $('#tot-due').html(data); 1834 }).fail(function(data) { 1835 $('#loading').hide(); 1836 showError(data); 1837 }); 1838 } 1839 } catch (e) { 1840 alert(e); 1841 } 1842} 1843 1844function changeCouponCode(){ 1845 try { 1846 var couponCode = trim($('#couponCodeApplied').val()); 1847 $('#loading').show(); 1848 // Carry the pay-now origin so the fragment keeps only "Check Out" after a rebuild (same as applyCouponCode). 1849 var payNowFlag = ($('#payNowOrigin').val() === 'true') ? '&payNow=1' : ''; 1850 $.ajax({ 1851 url : 'change-coupon-code?couponCode=' + couponCode + '&token=' + ($('#registrationToken').val() || '') + payNowFlag, 1852 context : document.body 1853 }).done(function(data) { $('#loading').hide(); 1854 $('#tot-due').html(data); 1855 }).fail(function(data) { 1856 $('#loading').hide(); 1857 showError(data); 1858 }); 1859 } catch (e) { 1860 alert(e); 1861 } 1862} 1863 1864function pagingBest(urlNam, no) { 1865 try{ 1866 if (urlNam == 'sPlacementExam') { 1867 var urlStr = '&ajax=true'; var subjectId = trim($('#subjectId').val()); 1868 var placementStudentTestId = trim($('#placementStudentTestId').val()); 1869 var placementStudentId = trim($('#placementStudentId').val()); 1870 var testId = trim($('#testId').val()); 1871 var placementStudentExamId = trim($('#placementStudentExamId').val()); 1872 var directionId = trim($('#directionId').val()); 1873 var parentId = trim($('#parentId').val()); 1874 var studentId = trim($('#studentId').val()); var prevDateString = trim($('#prevDateString').val()); 1875 1876 if (subjectId != undefined && subjectId != '') { 1877 urlStr += '&subjectId=' + subjectId; 1878 } 1879 if (placementStudentTestId != undefined && placementStudentTestId != '') { 1880 urlStr += '&placementStudentTestId=' + placementStudentTestId; 1881 } 1882 if (placementStudentId != undefined && placementStudentId != '') { 1883 urlStr += '&placementStudentId=' + placementStudentId; 1884 } 1885 if (testId != undefined && testId != '') { 1886 urlStr += '&testId=' + testId; 1887 } 1888 if (placementStudentExamId != undefined && placementStudentExamId != '') { 1889 urlStr += '&placementStudentExamId=' + placementStudentExamId; 1890 } 1891 if (directionId != undefined && directionId != '') { 1892 urlStr += '&directionId=' + directionId; 1893 } 1894 if (parentId != undefined && parentId != '') { 1895 urlStr += '&parentId=' + parentId; 1896 } 1897 if (studentId != undefined && studentId != '') { 1898 urlStr += '&studentId=' + studentId; 1899 } 1900 if (prevDateString != undefined && prevDateString != '') { 1901 urlStr += '&prevDateString=' + prevDateString; 1902 } 1903 $('#loading').show(); 1904 $.ajax({
1905 url : 'questions?pageNo=' + no + urlStr, 1906 context : document.body 1907 }).done(function(data) { 1908 serializeQuestions(placementStudentTestId, placementStudentExamId, placementStudentId, 1909 subjectId, testId, directionId, parentId, studentId, prevDateString); 1910 $('#loading').hide(); 1911 $('#exam-direction-list').html(data); 1912 $(window).scrollTop(0); 1913 MathJax.Hub.Queue(["Typeset",MathJax.Hub,'view']); 1914 }).fail(function(data) { 1915 $('#loading').hide(); 1916 showError(data); 1917 }); 1918 } else if (urlNam == 'skipDirection') { 1919 var urlStr = ''; var placementStudentId = trim($('#placementStudentId').val()); 1920 var placementStudentTestId = trim($('#placementStudentTestId').val()); 1921 var subjectId = trim($('#subjectId').val()); var testId = trim($('#testId').val()); 1922 var directionId = trim($('#directionId').val()); 1923 var prevDateString = trim($('#prevDateString').val()); 1924 1925 if (subjectId != undefined && subjectId != '') { 1926 urlStr += '&subjectId=' + subjectId; 1927 } 1928 if (placementStudentTestId != undefined && placementStudentTestId != '') { 1929 urlStr += '&placementStudentTestId=' + placementStudentTestId; 1930 } 1931 if (placementStudentId != undefined && placementStudentId != '') { 1932 urlStr += '&placementStudentId=' + placementStudentId; 1933 } 1934 if (testId != undefined && testId != '') { 1935 urlStr += '&testId=' + testId; 1936 } 1937 if (directionId != undefined && directionId != '') { 1938 urlStr += '&directionId=' + directionId; 1939 } 1940 if (prevDateString != undefined && prevDateString != '') { 1941 urlStr += '&prevDateString=' + prevDateString; 1942 } 1943 $('#loading').show(); 1944 $.ajax({ 1945 url : 'skip-direction?pageNo=' + no + urlStr, 1946 context : document.body 1947 }).done(function(data) { 1948 $('#loading').hide(); 1949 $('#exam-direction-list').html(data); 1950 MathJax.Hub.Queue(["Typeset",MathJax.Hub,'view']); 1951 }).fail(function(data) { 1952 $('#loading').hide(); 1953 showError(data); 1954 }); 1955 } 1956 } catch (e) { 1957 alert(e); 1958 } 1959} 1960 1961function serializeQuestions(placementStudentTestId, placementStudentExamId, placementStudentId, 1962 subjectId, testId, directionId, parentId, studentId, prevDateString) { 1963 try { 1964 var que = {}; var qInputs = {}; var k =''; var q = []; 1965 $("input[name='question']").each(function(data) { 1966 que[data] = this.value; 1967 }); 1968 $.each(que, function(i, val){ 1969 if($("textarea[name='a-"+ val +"-textarea']").is("textarea")){ 1970 var t = $("textarea[name='a-"+ val +"-textarea']").val(); 1971 $("input[name='a-"+ val +"']").val(t); 1972 } 1973 if($("input[name='qId-"+ val +"-radio']").is(':radio')){ 1974 var a = $("input[name='qId-"+ val +"-radio']:checked").val(); 1975 if(a != 'undefined' && a != undefined){ 1976 $("input[name='a-"+ val +"']").val(a+'`op'); 1977 }else{ 1978 $("input[name='a-"+ val +"']").val('0`op'); 1979 } 1980 } 1981 if($("input[name='qId-"+ val +"-chkbx']").is(':checkbox')){ 1982 var count = 1; 1983 $("input[name='qId-"+ val +"-chkbx']").each(function () { 1984 if($(this).is(':checked')){ 1985 $('#a-'+val+'-'+count).val($(this).val()+'`op'); 1986 }else{ 1987 $('#a-'+val+'-'+count).val('0`op'); 1988 } 1989 count++; 1990 }); 1991 } 1992 $("input[name='a-"+ val +"']").each(function(data) { 1993 qInputs[data] = this.value; 1994 q.push([val+"~"+this.value]); 1995 }); 1996 }); 1997 1998 var questionsString = q.join("|"); 1999 $.ajax({ 2000 type : "POST", 2001 url : "save-exam-question", 2002 data : 'questionsString=' + encodeURIComponent(questionsString) + '&placementStudentTestId=' + placementStudentTestId + 2003 '&placementStudentExamId=' + placementStudentExamId + '&placementStudentId=' + placementStudentId + 2004 '&subjectId=' + subjectId + '&testId=' + testId + '&directionId=' + directionId + '&parentId=' + parentId + 2005 '&studentId=' + studentId + '&prevDateString=' + prevDateString 2006 }).done(function(data) { 2007 $('#loading').hide(); 2008 }).fail(function(data) { 2009 $('#loading').hide(); 2010 showError(data); 2011 }); 2012 } catch (e) { 2013 alert(e); 2014 } 2015} 2016 2017function endCurrentExamConfirmation(placementStudentTestId, subjectId, testId) { 2018 try { 2019 $.ajax({
2020 url : 'end-current-exam-confirmation?placementStudentTestId=' + placementStudentTestId + '&subjectId=' + 2021 subjectId + '&testId=' + testId, 2022 context : document.body 2023 }).done(function(data) { 2024 $('#end-exam-confirm').html(data); 2025 $('#end-exam-confirm').addClass('show-alert'); 2026 }).fail(function(data) { 2027 showError(data); 2028 }); 2029 } catch (e) { 2030 alert(e); 2031 } 2032} 2033 2034function endCurrentExam(placementStudentTestId, subjectId) { 2035 try{ 2036 var errMsg = ''; var placementStudentExamId = $('#placementStudentExamId').val(); 2037 var placementStudentId = $('#placementStudentId').val(); 2038 var testId = $('#testId').val(); var directionId = $('#directionId').val(); 2039 var parentId = $('#parentId').val(); var studentId = $('#studentId').val(); 2040 var prevDateString = $('#prevDateString').val(); 2041 var subject1TestId = $('#subject1TestId').val(); 2042 var subject2TestId = $('#subject2TestId').val(); 2043 var subject3TestId = $('#subject3TestId').val(); 2044 2045 $('#end-exam-confirm').html('');$('#end-exam-confirm').removeClass('show-alert'); 2046 2047 if (placementStudentTestId == undefined || placementStudentTestId == 'undefined' || placementStudentTestId == '') { 2048 errMsg += '<li>' + t("placement.test.id.not.found") + '</li>'; 2049 } 2050 if (subjectId == undefined || subjectId == 'undefined' || subjectId == '') { 2051 errMsg += '<li>' + t("subject.id.not.found") + '</li>'; 2052 } 2053 if (placementStudentExamId == undefined || placementStudentExamId == 'undefined' || placementStudentExamId == '') { 2054 errMsg += '<li>' + t("exam.id.not.found") + '</li>'; 2055 } 2056 if (placementStudentId == undefined || placementStudentId == 'undefined' || placementStudentId == '') { 2057 errMsg += '<li>' + t("placement.student.id.not.found") + '</li>'; 2058 } 2059 if (testId == undefined || testId == 'undefined' || testId == '') { 2060 errMsg += '<li>' + t("test.id.not.found") + '</li>'; 2061 } 2062 if (directionId == undefined || directionId == 'undefined' || directionId == '') { 2063 errMsg += '<li>' + t("direction.id.not.found") + '</li>'; 2064 } 2065 if (parentId == undefined || parentId == 'undefined' || parentId == '') { 2066 errMsg += '<li>' + t("parent.id.not.found") + '</li>'; 2067 } 2068 if (studentId == undefined || studentId == 'undefined' || studentId == '') { 2069 errMsg += '<li>' + t("student.id.not.found") + '\n</li>'; 2070 } 2071 if (prevDateString == undefined || prevDateString == 'undefined' || prevDateString == '') { 2072 errMsg += '<li>' + t("date.string.not.found") + '</li>'; 2073 } 2074 if (errMsg != '') { 2075 errMsg = '<li>' + t("placement.test.error.msg") + '</li>' + errMsg; 2076 showError(errMsg); 2077 return false; 2078 } else { $('#loading').show(); 2079 serializeQuestions(placementStudentTestId, placementStudentExamId, placementStudentId, 2080 subjectId, testId, directionId, parentId, studentId, prevDateString); 2081 2082 window.location.href = "end-current-exam?placementStudentTestId="+placementStudentTestId+"&subjectId="+subjectId+"&testId="+testId; 2083 } 2084 } catch (e) { 2085 alert(e); 2086 } 2087} 2088 2089function endAllTests(placementStudentTestId) { 2090 try { 2091 var errMsg = ''; 2092 if (placementStudentTestId == undefined || placementStudentTestId == 'undefined' || placementStudentTestId == '') { 2093 errMsg += '<li>' + placementTestIDNotFoundMsg + '</li>'; 2094 } 2095 if (errMsg != '') { 2096 showError(errMsg); 2097 return false; 2098 } else { $('#loading').show(); 2099 window.location.href = "end-all-tests-"+placementStudentTestId; 2100 } 2101 } catch (e) { 2102 alert(e); 2103 } 2104} 2105 2106function sendTestCompletionMail(placementStudentTestId){ 2107 try{ 2108 $.ajax({ 2109 url : 'send-test-completed-mail-to-center-' + placementStudentTestId, 2110 context : document.body 2111 }).done(function(data) { 2112 $('#loading').hide(); 2113 }).fail(function(data) { 2114 $('#loading').hide(); 2115 }); 2116 } catch (e) { 2117 alert(e); 2118 } 2119} 2120 2121function searchBlog(pageNo) { 2122 try { 2123 var errMsg = ''; 2124 var h1Tag = trim($('#h1Tag').val()); 2125 2126 if (h1Tag == undefined || h1Tag == 'undefined' || h1Tag == '') { 2127 errMsg += enterTheTextMsg; 2128 } 2129 if (errMsg != '') { 2130 showError(errMsg); 2131 } else { 2132 $('#loading').show(); 2133 $.ajax({
2134 url : 'search-blog', 2135 type : "POST", 2136 data : 'pageNo=' + pageNo + "&h1Tag=" + h1Tag, 2137 context : document.body 2138 }).done(function(data) { 2139 $('#user-blog-list').html(data); 2140 $('#loading').hide();$(".modal-backdrop").css({display:'none'}); 2141 }).fail(function(data) { 2142 showError(data); 2143 $('#loading').hide();$(".modal-backdrop").css({display:'none'}); 2144 }); 2145 } 2146 } catch (e) { 2147 alert(e); 2148 } 2149} 2150 2151/* Toggles the floating "enter email in English" hint next to the email label's info icon. 2152 Click/tap based so it works on mobile (where the language guidance is most relevant) as well 2153 as desktop; the hint is an absolutely-positioned popover (see .email-lang-hint CSS), so it 2154 overlays rather than pushing the form layout. */ 2155function toggleEmailLangHint(icon) { 2156 var hint = icon.parentNode.querySelector('.email-lang-hint'); 2157 if (!hint) { 2158 return; 2159 } 2160 var willShow = !hint.classList.contains('show'); 2161 document.querySelectorAll('.email-lang-hint.show').forEach(function (h) { h.classList.remove('show'); }); 2162 if (willShow) { 2163 hint.classList.add('show'); 2164 } 2165} 2166 2167/* Close any open email-language hint when clicking outside its icon/box. */ 2168document.addEventListener('click', function (e) { 2169 if (!e.target.closest('.email-info-wrap')) { 2170 document.querySelectorAll('.email-lang-hint.show').forEach(function (h) { h.classList.remove('show'); }); 2171 } 2172});
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.