1.2.2 • Published 6 years ago
@laps.no/intl-tel-input v1.2.2
@laps.no/intl-tel-input
Standalone web component of the intl-tel-input package.
Installation
Standalone
<script src='https://unpkg.com/@laps.no/intl-tel-input/dist/intl-tel-input.js'></script>
Stencil JS
npm i '@laps.no/intl-tel-input'
import '@laps.no/intl-tel-input';
Usage
<intl-tel-input id="numberInput"
name="phoneNumber"
required="false"
countries="no,de,gb" />
Attributes
name Name of the form input field.
required Specifies if the field must be filled out before submitting the form.
countries List of preffered countries as a comma-seperated string.
Default: "no,se,dk,gb,us"
Public Methods
const input = document.getElementById("numberInput");
getNumber
Get the current number in the given format (defaults to E.164 standard).
const number = input.getNumber();
Returns a string e.g. "+17024181234"
isValidNumber
Validate the current number
var isValid = input.isValidNumber();
Returns: true
/false
setCountry
Change the country selection (e.g. when the user is entering their address).
input.setCountry("gb");
setNumber
Insert a number, and update the selected flag accordingly.
input.setNumber("+447733123456");