JavaScript Code to Validate Phone Number Input Based on Country (How to use libphonenumber in few steps)
While I was working on a submit form built using HubSpot marketing forms and templates. The client requested to validate the phone number field based on the selected country code. For instance, if user choose France for country code then there should be 9 digits in the phone number, so the number of digits and format should be validated according to the selected country code. Here is a screenshot of the form: I tried many solutions but the best approach was to use an online API that can validate the pho…