• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

InputPhone

InputPhone is an input for international phone numbers with a country selector. The number is formatted while typing and submitted in the E.164 format (e.g. +4930123456), numbers that are not valid for their country are rejected. Formatting and validation are based on libphonenumber-js, on the server Google's libphonenumber is used if it is available.

InputPhone Tag Documentation

InputPhone is an input for international phone numbers with a country selector, the value is the number in the E.164 format (e.g. +4930123456).

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
accesskey String false Access key to transfer focus to the input element.
allowDropdown boolean false true Lets the user select the country, otherwise only the initial country (or the one of the value) is shown.
alt String false Alternate textual description of the input field.
appendTo String false @(body) Appends the country panel to the element defined by search expression.
ariaDescribedBy String false Identifies the element(s) that describe the object, enhancing accessibility.
ariaLabelledBy String false
autoHideDialCode boolean false true In the international format (nationalMode=false): the calling code of the selected country is filled in when the empty input gets the focus and removed again if nothing else is entered.
autoPlaceholder String false polite Example mobile number of the selected country as placeholder: "polite" if no placeholder is set, "aggressive" also replaces the placeholder, "off" never.
autocomplete String false Controls browser autocomplete behavior. Possible values are 'on', 'off', and 'new-password'.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage String false Custom message to display when conversion fails.
dir String false ltr Direction indication for text that does not inherit directionality.
disabled boolean false false Specifies that an element should be disabled.
excludeCountries Object false Countries the user can not select (ISO 3166-1 alpha-2 codes), a comma separated String or a Collection.
fixDropdownWidth boolean false true The country panel has the width of the component, otherwise it grows with the longest name.
formatAsYouType boolean false true Formats the number while the user types.
formatOnDisplay boolean false true Formats the value when it is displayed, otherwise it is shown as it is (E.164).
geoIpLookup String false Client side function(success, failure) that looks up the country of the user for initialCountry="auto", e.g. with a geo IP service, and calls success(countryCode).
immediate boolean false false When set true, process validations logic is executed at apply request values phase for this component.
initialCountry String false Country (ISO 3166-1 alpha-2 code, e.g. DE) selected when the value is empty, "auto" looks it up with geoIpLookup. Defaults to the country of the view locale, US if the locale has none.
inputStyle String false Inline style of the input.
inputStyleClass String false Style class of the input.
inputmode String false Specifies the type of data expected in the input, aiding virtual keyboards.
label String false A localized user presentable name.
lang String false Specifies the language of the element's content.
localValueSet boolean false false Indicates whether the local value of the component has been set.
localizedCountries Map false Names of the countries (a Map of ISO 3166-1 alpha-2 code to name), replaces the names of the browser in the language of the page.
maxlength int false Integer.MIN_VALUE Defines the maximum number of characters allowed in the input.
nationalMode boolean false true Shows the number in the national format (e.g. 030 123456), otherwise in the international format (+49 30 123456).
onblur String false Fires when an element loses focus.
onchange String false Fires when the value of an element has been changed.
onclick String false Fires when a mouse click on the element.
oncontextmenu String false Script to execute when the context menu is triggered.
oncopy String false Script to execute when content is copied from the element.
oncut String false Script to execute when content is cut from the element.
ondblclick String false Fires when a mouse double-click on the element.
ondrag String false Script to execute when an element is dragged.
ondragend String false Script to execute at the end of a drag operation.
ondragenter String false Script to execute when a dragged element enters a valid drop target.
ondragleave String false Script to execute when a dragged element leaves a valid drop target.
ondragover String false Script to execute when a dragged element is over a valid drop target.
ondragstart String false Script to execute at the start of a drag operation.
ondrop String false Script to execute when a dragged element is dropped.
onfocus String false Fires when an element gets focus.
oninput String false Script to execute when the element receives user input.
oninvalid String false Script to execute when the element's value is invalid.
onkeydown String false Fires when a user is pressing a key.
onkeypress String false Fires when a user presses a key.
onkeyup String false Fires when a user releases a key.
onlyCountries Object false Countries the user can select (ISO 3166-1 alpha-2 codes), a comma separated String or a Collection.
onmousedown String false Fires when a mouse button is pressed down on an element.
onmousemove String false Fires when the mouse pointer is moving while it is over an element.
onmouseout String false Fires when the mouse pointer moves out of an element.
onmouseover String false Fires when the mouse pointer moves onto an element.
onmouseup String false Fires when a mouse button is released over an element.
onpaste String false Script to execute when content is pasted into the element.
onreset String false Script to execute when the form is reset.
onscroll String false Script to execute when the element is scrolled.
onsearch String false Script to execute when a search is performed.
onselect String false Script to execute when text is selected.
onwheel String false Script to execute when the mouse wheel is used.
placeholder String false Specifies a short hint describing the expected value of the input.
preferredCountries Object false Countries listed at the top (ISO 3166-1 alpha-2 codes), a comma separated String or a Collection.
readonly boolean false false Specifies that an input field is read-only.
required boolean false false Marks component as required.
requiredMessage String false Custom message to display when the required validation fails.
role String false Defines the role of the element for accessibility purposes.
separateDialCode boolean false true Shows the calling code of the selected country next to its code in the country selector.
size int false Integer.MIN_VALUE Number of characters used to determine the width of the input element.
style String false Specifies an inline CSS style for an element.
styleClass String false Specifies one or more CSS class names for an element.
submittedValue Object false
tabindex String false Specifies the tab order of an element.
title String false Specifies extra information about an element (displayed as a tooltip).
type String false text Input field type.
valid boolean false true Indicates whether the input's value is valid.
validator Validator false A method expression referring to a method validating the input.
validatorMessage String false Custom message to display when validation fails.
value Object false Value of the component.
valueChangeListener ValueChangeListener false A method binding expression referring to a method for handling a valuchangeevent.
Loading...
Tag Documentation Documentation Documentation JSDoc
Basic

The country is selected in the panel or follows a number entered with its calling code (e.g. +44 20 7946 0958).

International Format

With nationalMode="false" the number is shown with its calling code, which is filled in when the empty input gets the focus.

Countries
GB
Variants
US
Client Side Validation

The number is validated in the browser before the form is submitted.

Usage


<p:growl>
    <p:autoUpdate/>
</p:growl>

<h:form>
    <div class="card">
        <h5 class="mt-0">Basic</h5>
        <p class="mt-0">The country is selected in the panel or follows a number entered with its calling code (e.g. +44 20 7946 0958).</p>
        <div class="p-fluid formgrid grid">
            <div class="field col-12 md:col-6">
                <p:outputLabel for="phone" value="Phone"/>
                <p:inputPhone id="phone" value="#{inputPhoneView.phone}" label="Phone">
                    <p:ajax event="countrySelect" listener="#{inputPhoneView.onCountrySelect}"/>
                </p:inputPhone>
                <p:message for="phone"/>
            </div>

            <div class="field col-12 md:col-6">
                <p:outputLabel for="mobile" value="With value"/>
                <p:inputPhone id="mobile" value="#{inputPhoneView.mobile}" label="Mobile"/>
                <p:message for="mobile"/>
            </div>
        </div>
    </div>

    <div class="card">
        <h5 class="mt-0">International Format</h5>
        <p class="mt-0">With <i>nationalMode="false"</i> the number is shown with its calling code, which is filled in when the empty input gets the focus.</p>
        <div class="p-fluid formgrid grid">
            <div class="field col-12 md:col-6">
                <p:outputLabel for="international" value="International"/>
                <p:inputPhone id="international" value="#{inputPhoneView.international}" nationalMode="false"
                              separateDialCode="false" label="International"/>
                <p:message for="international"/>
            </div>
        </div>
    </div>

    <div class="card">
        <h5 class="mt-0">Countries</h5>
        <div class="p-fluid formgrid grid">
            <div class="field col-12 md:col-6">
                <p:outputLabel for="office" value="Only DACH countries, Switzerland preselected"/>
                <p:inputPhone id="office" value="#{inputPhoneView.office}" onlyCountries="DE,AT,CH"
                              initialCountry="CH" label="Office"/>
                <p:message for="office"/>
            </div>

            <div class="field col-12 md:col-6">
                <p:outputLabel for="preferred" value="Preferred countries"/>
                <p:inputPhone id="preferred" preferredCountries="US,GB,DE,FR"/>
            </div>

            <div class="field col-12 md:col-6">
                <p:outputLabel for="fixed" value="Fixed country"/>
                <p:inputPhone id="fixed" initialCountry="GB" allowDropdown="false"/>
            </div>

            <div class="field col-12 md:col-6">
                <p:outputLabel for="excluded" value="Excluded countries, wide panel"/>
                <p:inputPhone id="excluded" excludeCountries="US,CA" fixDropdownWidth="false"/>
            </div>
        </div>
    </div>

    <div class="card">
        <h5 class="mt-0">Variants</h5>
        <div class="p-fluid formgrid grid">
            <div class="field col-12 md:col-4">
                <p:outputLabel for="small" value="Small"/>
                <p:inputPhone id="small" inputStyleClass="p-inputtext-sm"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel for="filled" value="Filled"/>
                <p:inputPhone id="filled" styleClass="p-input-filled"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel for="large" value="Large"/>
                <p:inputPhone id="large" inputStyleClass="p-inputtext-lg"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel for="placeholder" value="Placeholder"/>
                <p:inputPhone id="placeholder" placeholder="Your phone number"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel for="readonly" value="Readonly"/>
                <p:inputPhone id="readonly" value="+33123456789" readonly="true"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel for="disabled" value="Disabled"/>
                <p:inputPhone id="disabled" value="+33123456789" disabled="true"/>
            </div>
        </div>

        <p:commandButton value="Submit" action="#{inputPhoneView.submit}" update="@form"/>
    </div>
</h:form>

<h:form>
    <div class="card">
        <h5 class="mt-0">Client Side Validation</h5>
        <p class="mt-0">The number is validated in the browser before the form is submitted.</p>
        <div class="p-fluid formgrid grid">
            <div class="field col-12 md:col-6">
                <p:outputLabel for="csv" value="Phone"/>
                <p:inputPhone id="csv" value="#{inputPhoneView.csv}" required="true" label="Phone"/>
                <p:message for="csv"/>
            </div>
        </div>
        <p:commandButton value="Submit" action="#{inputPhoneView.submit}" update="@form" validateClient="true"/>
    </div>
</h:form>