We need to know the country code of all numbers submitted through our forms. It would be ideal if there was a country code drop down to select from that we could have on our web formsThis is what HubSpot has on their forms on their website
Not at the moment no, we don't currently allow for customisations on the inputs. I can see how this would be helpful though and the screenshot you've sent isn't the prettiest of sights. I'll be sure to bring this up with the team to see if it's something we can fit in in the future!
Hi @lien yes this is has been tested and we released this in beta to customers who have had no issues. This may be due to the form you're using. Could you open a ticket with our support team who can assist you with this issue please?
Hi all, this has just been released to all portals today. You can find this by adding the "phone" field to your HubSpot form, clicking this within the editor and enabling "show country code dropdown".
Thanks to everyone for your continued feedback in helping us build a great product!
I've got some exciting news - this feature is now in Beta so if you are interested in rying it out please DM me your Portal ID and I will add it to your account.
Hi everyone, I'm excited to tell you that we've been working on this feature for a while now and will have a beta version of this feature ready in the next couple of weeks. I will be updating the status of this post as soon as the beta is ready so you are welcome to reply on this post if you are interested in joining it.
It would be very useful for some of my clients if the 'country code' for the phone number is auto populated if the country has been selected from the dropdown list.
It will save a lot of time at the events where people are attending from the world and to search for their country code can be a task (especially if the event is too busy).
Agreed. Everybody has more than two phone numbers. There could be office numbers and direct line numbers and such which we can't use the calling functionality on.
THis is a feature now. BUt country names are WAY to long! this gives issues for Google, because the text does not fit in the box. So the country names should be the short abriviations : Netherlands = NL
Looks like I'm a little late to the party, but here is how I overwrote the style to show the flags. You might have to play around with CSS but this can serve as a base:
Everything kicks in after the JS listener hears the event 'ofFormReady' fired from hubspot:
// Add an event listener to the window object that listens for 'message' events.
window.addEventListener('message', event => {
// Check if the message event is of type 'hsFormCallback' and the eventName is 'onFormReady'.
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
// Find the form element in the document with a matching 'data-form-id' attribute.
let initedForm = document.querySelector(`[data-form-id="${event.data.id}"]`);
// Query all elements with class 'hs_phone' within the found form.
let phoneNumberFields = initedForm.querySelectorAll('.hs_phone');
// Iterate over each 'hs_phone' element.
phoneNumberFields.forEach(numberField => {
// Find a 'select' element within the current phone number field.
let statesDropdown = numberField.querySelector('select');
// If there is no 'select' element, skip the rest of this iteration.
if (!statesDropdown) return;
// Set a CSS custom property '--bg-flag' on the number field to the URL of a flag icon
// based on the current value of the dropdown. The flag icons are sourced from an external URL.
numberField.style.setProperty('--bg-flag', `url(https://purecatamphetamine.github.io/country-flag-icons/3x2/${statesDropdown.value}.svg)`);
// Add an event listener to the dropdown for 'change' events.
statesDropdown.addEventListener('change', function () {
// When the dropdown value changes, update the '--bg-flag' property to reflect the new selection.
numberField.style.setProperty('--bg-flag', `url(https://purecatamphetamine.github.io/country-flag-icons/3x2/${this.value}.svg)`);
});
});
}
});
And then here is the css overrides I used, which very likely will not work on your case, as these are on top of the CSS I wrote from scatch on my theme: