templates/login/_loginBoxJs.html.twig line 1

Open in your IDE?
  1. {% include 'backOffice/appParts/_addressAutocompleteGoogleJs.html.twig' with {'inputId':'request_access_addressLine1'} %}
  2. {% include 'backOffice/appParts/phoneNumberJs.html.twig' %}
  3. <script src="{{ asset('js/plugins/jquery.validate.min.js') }}"></script>
  4. <script>
  5.     //Validate form when click on btn Submit.
  6.     $(function() {
  7.         $.validator.addMethod("validatePhoneNumberFormat", function (value, element) {
  8.             let regex = $(element).attr('data-regex');
  9.             let pattern = new RegExp(regex);
  10.             return pattern.test(value);
  11.         }, function(value, element) {
  12.             return "Format is not valid. It must be "+$(element).attr('placeholder');
  13.         });
  14.         $("form[name='request_access']").validate({
  15.             rules: {
  16.                 "request_access[phone]": {
  17.                     required: true,
  18.                     validatePhoneNumberFormat:true
  19.                 }
  20.             },
  21.             submitHandler: function(form) {
  22.                 submitSpinnerSecondaryBtn("#submitBtn");
  23.                 submitSpinnerForm(form);
  24.                 form.submit();
  25.             }
  26.         });
  27.     });
  28.     //END Validate form when click on btn Submit.
  29. </script>
  30. <script>
  31.     initPhoneNumberFormat('request_access_phone',false,'request_access_phoneCountryCode');
  32.     $(document).ready(function () {
  33.         //Open the tab by the url
  34.         const hash = window.location.hash;
  35.         if (hash.match('#')) {
  36.             let tabObj = document.querySelector("#"+$('a[href="'+hash+'"].nav-link').attr('id'));
  37.             let tab = new bootstrap.Tab(tabObj);
  38.             tab.show();
  39.         }
  40.         //End: Open the tab on url
  41.         {% if openGetStarted is defined and openGetStarted %}
  42.         $('#signup-tab').tab('show');
  43.         {% endif %}
  44.         $(".openGetStarted").click(function (){
  45.             $('#signup-tab').tab('show');
  46.         });
  47.         //Sort country
  48.         // sortCountries(document.getElementById('request_access_country'));
  49.         // function sortCountries(countriesElem) {
  50.         //     let countriesTop=["","United States","United Kingdom","France","Belgium","Brazil","Canada","Germany","India","Italy","Mexico","Netherlands","Spain","Switzerland","Venezuela"];
  51.         //     var tempTopCountries = new Array();
  52.         //     var tempDownCountries = new Array();
  53.         //     let j=0;
  54.         //     for (var i=0;i<countriesElem.options.length;i++) {
  55.         //         if (countriesTop.indexOf(countriesElem.options[i].text) != -1)
  56.         //         {
  57.         //             // found it
  58.         //             let countryTopIndex=countriesTop.indexOf(countriesElem.options[i].text);
  59.         //             tempTopCountries[countryTopIndex] = new Array();
  60.         //             tempTopCountries[countryTopIndex][0] = countriesElem.options[i].text;
  61.         //             tempTopCountries[countryTopIndex][1] = countriesElem.options[i].value;
  62.         //         }
  63.         //         else{
  64.         //             tempDownCountries[j] = new Array();
  65.         //             tempDownCountries[j][0] = countriesElem.options[i].text;
  66.         //             tempDownCountries[j][1] = countriesElem.options[i].value;
  67.         //             j++;
  68.         //         }
  69.         //     }
  70.         //
  71.         //     while(countriesElem.options.length > 0) {
  72.         //         countriesElem.options[0] = null;
  73.         //     }
  74.         //
  75.         //     i=0;
  76.         //     var op = new Option("Please choose","");
  77.         //     countriesElem.options[i] = op;
  78.         //     i++;
  79.         //
  80.         //     //Add to the dropdown list the top countries
  81.         //     while(i<tempTopCountries.length) {
  82.         //         op = new Option(tempTopCountries[i][0], tempTopCountries[i][1]);
  83.         //         countriesElem.options[i] = op;
  84.         //         i++
  85.         //     }
  86.         //
  87.         //     //Add to the dropdown list the other countries
  88.         //     var group = $('<optgroup label="---" />');
  89.         //
  90.         //     j=1;
  91.         //     group.appendTo(countriesElem);
  92.         //     while (j<tempDownCountries.length) {
  93.         //         op = new Option(tempDownCountries[j][0], tempDownCountries[j][1]);
  94.         //         countriesElem.options[i] = op;
  95.         //         i++;
  96.         //         j++;
  97.         //     }
  98.         //     return;
  99.         // }
  100.         // //End: Sort country
  101.         {#$("#request_access_country").change(function () {#}
  102.         {#    let stateSelect = $("#request_access_state");#}
  103.         {#    let data = {idCountry: $(this).val()};#}
  104.         {#    stateSelect.val(null); // clear out values selected#}
  105.         {#    stateSelect.attr('value', ''); // re-init to show default status#}
  106.         {#    stateSelect.attr('required',false);#}
  107.         {#    $.ajax({#}
  108.         {#        type: 'post',#}
  109.         {#        url: "{{ path('states_by_country') }}",#}
  110.         {#        data: data,#}
  111.         {#        success: function (data) {#}
  112.         {#            stateSelect.attr('required','required');#}
  113.         {#            stateSelect.html(' ');#}
  114.         {#            stateSelect.append('<option  value="" selected="selected">Please Choose</option>');#}
  115.         {#            for (let i = 0, total = data.length; i < total; i++) {#}
  116.         {#                stateSelect.append('<option value="' + data[i].id + '">' + data[i].name + ' </option>');#}
  117.         {#            }#}
  118.         {#            let countrySelectCol = $('#countryCol');#}
  119.         {#            let stateSelectCol = $('#stateCol');#}
  120.         {#            if(data.length){#}
  121.         {#                countrySelectCol.addClass('col-md-6');#}
  122.         {#                countrySelectCol.removeClass('col-md-12');#}
  123.         {#                stateSelectCol.removeClass('d-none');#}
  124.         {#                stateSelect.prop( "disabled", false );#}
  125.         {#            }else{#}
  126.         {#                countrySelectCol.addClass('col-md-12');#}
  127.         {#                countrySelectCol.removeClass('col-md-6');#}
  128.         {#                stateSelectCol.addClass('d-none');#}
  129.         {#                stateSelect.prop( "disabled", true );#}
  130.         {#            }#}
  131.         {#        }#}
  132.         {#    });#}
  133.         {#});#}
  134.     });
  135. </script>