Hi,
So i have managed to do what i want. I have added some autocomplete to address_city, search post code button to address_post_code and phone number regex to address_telephone.
Now i was thinking how should i handle this for international people. From all possible solutions i think the best would be to run this js functions based on country selected so i wont need to have more fields.
However as much as i try it doesnt work. As example i have this:
$(document).ready(function() {
$('#address_country').change(function() {
var thisVal = $(this).val();
if(thisVal=='country_Lithuania_123') {
$('#address_city').autocomplete({
source: function (request, response) {
$.getJSON("https://www.mysite.com/ajax_autoservice.php?fnc=myAmazingFunction&term=" + request.term, function( data, status, xhr ) {
response( $.map( data, function( item ) {
return {
value: item.label,
}
}));
});
},
minLength: 3,
delay: 200
});
}
});
});
It does work always and looking into html it seems default country is always preselected. On choosing another country from dropdown it still shows default selected value. Please check images.
I have spent some time and could find a way how to run my js based on selected value/country.
Could i have help here please?
Thank you