{% include 'backOffice/appParts/_addressAutocompleteGoogleJs.html.twig' with {'inputId':'request_access_addressLine1'} %}
{% include 'backOffice/appParts/phoneNumberJs.html.twig' %}
<script src="{{ asset('js/plugins/jquery.validate.min.js') }}"></script>
<script>
//Validate form when click on btn Submit.
$(function() {
$.validator.addMethod("validatePhoneNumberFormat", function (value, element) {
let regex = $(element).attr('data-regex');
let pattern = new RegExp(regex);
return pattern.test(value);
}, function(value, element) {
return "Format is not valid. It must be "+$(element).attr('placeholder');
});
$("form[name='request_access']").validate({
rules: {
"request_access[phone]": {
required: true,
validatePhoneNumberFormat:true
}
},
submitHandler: function(form) {
submitSpinnerSecondaryBtn("#submitBtn");
submitSpinnerForm(form);
form.submit();
}
});
});
//END Validate form when click on btn Submit.
</script>
<script>
initPhoneNumberFormat('request_access_phone',false,'request_access_phoneCountryCode');
$(document).ready(function () {
//Open the tab by the url
const hash = window.location.hash;
if (hash.match('#')) {
let tabObj = document.querySelector("#"+$('a[href="'+hash+'"].nav-link').attr('id'));
let tab = new bootstrap.Tab(tabObj);
tab.show();
}
//End: Open the tab on url
{% if openGetStarted is defined and openGetStarted %}
$('#signup-tab').tab('show');
{% endif %}
$(".openGetStarted").click(function (){
$('#signup-tab').tab('show');
});
//Sort country
// sortCountries(document.getElementById('request_access_country'));
// function sortCountries(countriesElem) {
// let countriesTop=["","United States","United Kingdom","France","Belgium","Brazil","Canada","Germany","India","Italy","Mexico","Netherlands","Spain","Switzerland","Venezuela"];
// var tempTopCountries = new Array();
// var tempDownCountries = new Array();
// let j=0;
// for (var i=0;i<countriesElem.options.length;i++) {
// if (countriesTop.indexOf(countriesElem.options[i].text) != -1)
// {
// // found it
// let countryTopIndex=countriesTop.indexOf(countriesElem.options[i].text);
// tempTopCountries[countryTopIndex] = new Array();
// tempTopCountries[countryTopIndex][0] = countriesElem.options[i].text;
// tempTopCountries[countryTopIndex][1] = countriesElem.options[i].value;
// }
// else{
// tempDownCountries[j] = new Array();
// tempDownCountries[j][0] = countriesElem.options[i].text;
// tempDownCountries[j][1] = countriesElem.options[i].value;
// j++;
// }
// }
//
// while(countriesElem.options.length > 0) {
// countriesElem.options[0] = null;
// }
//
// i=0;
// var op = new Option("Please choose","");
// countriesElem.options[i] = op;
// i++;
//
// //Add to the dropdown list the top countries
// while(i<tempTopCountries.length) {
// op = new Option(tempTopCountries[i][0], tempTopCountries[i][1]);
// countriesElem.options[i] = op;
// i++
// }
//
// //Add to the dropdown list the other countries
// var group = $('<optgroup label="---" />');
//
// j=1;
// group.appendTo(countriesElem);
// while (j<tempDownCountries.length) {
// op = new Option(tempDownCountries[j][0], tempDownCountries[j][1]);
// countriesElem.options[i] = op;
// i++;
// j++;
// }
// return;
// }
// //End: Sort country
{#$("#request_access_country").change(function () {#}
{# let stateSelect = $("#request_access_state");#}
{# let data = {idCountry: $(this).val()};#}
{# stateSelect.val(null); // clear out values selected#}
{# stateSelect.attr('value', ''); // re-init to show default status#}
{# stateSelect.attr('required',false);#}
{# $.ajax({#}
{# type: 'post',#}
{# url: "{{ path('states_by_country') }}",#}
{# data: data,#}
{# success: function (data) {#}
{# stateSelect.attr('required','required');#}
{# stateSelect.html(' ');#}
{# stateSelect.append('<option value="" selected="selected">Please Choose</option>');#}
{# for (let i = 0, total = data.length; i < total; i++) {#}
{# stateSelect.append('<option value="' + data[i].id + '">' + data[i].name + ' </option>');#}
{# }#}
{# let countrySelectCol = $('#countryCol');#}
{# let stateSelectCol = $('#stateCol');#}
{# if(data.length){#}
{# countrySelectCol.addClass('col-md-6');#}
{# countrySelectCol.removeClass('col-md-12');#}
{# stateSelectCol.removeClass('d-none');#}
{# stateSelect.prop( "disabled", false );#}
{# }else{#}
{# countrySelectCol.addClass('col-md-12');#}
{# countrySelectCol.removeClass('col-md-6');#}
{# stateSelectCol.addClass('d-none');#}
{# stateSelect.prop( "disabled", true );#}
{# }#}
{# }#}
{# });#}
{#});#}
});
</script>