Captive Portal - Phone Number Country Code

  • 1
  • Question
  • Updated 8 months ago
We currently have a number of  AP130 devices which provide guest internet. The users connect to one SSID which has a captive web portal, fill in their details and it then texts them the PPSK. When filling in their phone number, it currently defaults to US and the user must then change this to UK. Is there a way of changing this to always default to UK for the phone number?
Photo of Chris Rule

Chris Rule

  • 1 Post
  • 0 Reply Likes

Posted 8 months ago

  • 1
Photo of Terence Fleming ThinkWireless

Terence Fleming ThinkWireless, Champ

  • 79 Posts
  • 27 Reply Likes
Download the default User-Auth-Self-Reg-Example and edit the index.html file.

We used this Javascript to set our country code. All you would need to do is change New Zealand to your desired default country and have a variable allCountries to iterate over.

                var content = '';
                // loop over all of the countries above
                for (var i = 0; i < allCountries.length; i++) {
                    var c = allCountries[i];
                    if('New Zealand' == c[0]){
                        content = content + '<option selected="selected" value="' + c[2] +'"> + ' + c[2] + ' - ' + c[0] + '</option>';
                    }else{
                        content = content + '<option value="' + c[2] +'"> + ' + c[2] + ' - ' + c[0] + '</option>';
                    }
                }

In New Zealand we also have mobile phone numbers beginning with 0 but need these numbers to begin with 64 (NZ country code). The following code recognizes a phone number beginning with a 0 and replaces it with the country code instead. (This code already exists in the file but we have added to it)

            function handleCountyCode(){
if(document.getElementById('phoneNumber').value.charAt(0)==0){
                document.getElementById('phone').value = document.getElementById('ccode').value + document.getElementById('phoneNumber').value.substring(1);
            }
else{
document.getElementById('phone').value = document.getElementById('ccode').value + document.getElementById('phoneNumber').value;
}
}

Hope this helps,

Felix Fleming