{"id":1732,"date":"2025-10-22T10:38:40","date_gmt":"2025-10-22T10:38:40","guid":{"rendered":"http:\/\/gogetmuscle.com\/?p=1732"},"modified":"2025-10-22T17:46:25","modified_gmt":"2025-10-22T17:46:25","slug":"phone-number-not-recording-all-the-time-on-hubspot-forms","status":"publish","type":"post","link":"http:\/\/gogetmuscle.com\/index.php\/2025\/10\/22\/phone-number-not-recording-all-the-time-on-hubspot-forms\/","title":{"rendered":"Phone number not recording all the time on Hubspot Forms"},"content":{"rendered":"
Hi there i have problem i wanted to implement select country flag from phone number and when i am testing sometimes phone number gets deleted before submited here is my full code\u00a0
<\/P>
for selecting phone country flag i am using this library\u00a0intlTelInput<\/P>
\u00a0<\/P>
<link rel="stylesheet" href="https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@19\/build\/css\/intlTelInput.min.css<\/a>” \/> function fireAmplitude(formId) { hbspt.forms.create({ if (!$form.find(‘input[name=”phone_full”]’).length) { var phoneInputField = $form.find(‘input[name=”phone”]’).get(0); if (hiddenPhoneInput.length) { fireAmplitude(hubspotFormId);<\/P> \/\/ DO NOT return false here to allow HubSpot native submission to proceed window.addEventListener(“message”, function(event) {
<\/P><\/p>\n
(function() {
var hubspotFormId = ‘4cf2cc85-1a88-44e0-9b65-aa3966e3ec67’;
var amplitudeFormName = ‘only6-female’;
if (!window[‘__hubspotFormSubmitted_’ + hubspotFormId]) {
window.amplitude && window.amplitude.track &&
window.amplitude.track(‘Form Submitted’, {
formId: formId,
formName: amplitudeFormName
});
window[‘__hubspotFormSubmitted_’ + hubspotFormId] = true;
}
}<\/P>
portalId: “XXX65354”,
formId: hubspotFormId,
region: “na1”,
onFormReady: function($form) {
setTimeout(function() {
var amplitudeDeviceId = $form.find(‘input[name=”amplitude_device_id”]’);
if (amplitudeDeviceId.length && window.amplitude && typeof window.amplitude.getDeviceId === ‘function’) {
amplitudeDeviceId.val(window.amplitude.getDeviceId()).change();
}
}, 2000);<\/P>
var hiddenInput = document.createElement(‘input’);
hiddenInput.type = ‘hidden’;
hiddenInput.name = ‘phone_full’;
$form[0].appendChild(hiddenInput);
}<\/P>
if (phoneInputField && window.intlTelInput) {
window.iti = window.intlTelInput(phoneInputField, {
separateDialCode: true,
initialCountry: “auto”,<\/P>
geoIpLookup: function(callback) {
fetch(‘https:\/\/ipapi.co\/json<\/A>‘)
.then(res => res.json())
.then(data => callback(data.country_code))
.catch(() => callback(‘us’));
},
useFullscreenPopup: false,
utilsScript: “https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@19\/build\/js\/utils.js<\/A>“
});
}
},
onFormSubmit: function($form) {
if (window.iti && window.intlTelInputUtils) {
var fullNumber = window.iti.getNumber(window.intlTelInputUtils.numberFormat.E164);
var hiddenPhoneInput = $form.find(‘input[name=”phone_full”]’);
var phoneInputField = $form.find(‘input[name=”phone”]’);<\/P>
hiddenPhoneInput.val(fullNumber).change();
}
if (phoneInputField.length) {
phoneInputField.val(fullNumber).change();
}
console.log(“phoneInputField”,phoneInputField.val());
\/\/ Force refresh validation (prevents HubSpot from wiping values)
phoneInputField.trigger(‘focus’).trigger(‘blur’);
}<\/P>
}
});<\/P>
if (
event.data &&
event.data.type === ‘hsFormCallback’ &&
event.data.eventName === ‘onFormSubmitted’ &&
event.data.id === hubspotFormId
) {
fireAmplitude(hubspotFormId);
}
}, false);
})();
<\/P>
<\/P><\/div>\n