MaskedField

MaskedField is a TextField that allows you to restrict and format the values that can be entered into it.

Component’s XML-name: maskedField.

Basics

MaskedField repeats the functionality of TextField, but it is convenient to use MaskedField for dates, social security numbers, tax IDs, and phone numbers, for example:

<layout spacing="true">
    <maskedField id="maskedField"
                 caption="Phone number"
                 mask="(###) ###-##-##"/>
</layout>
masked field

Attributes

mask

The mask attribute allows you to set a mask for the field. You can use the following characters:

  • # – number

  • U – uppercase letter

  • L – lowercase letter

  • ? – letter

  • А – letter or number

  • * – any character

  • H – uppercase hex character

  • h – lowercase hex character

  • ~ – plus (+) or minus (-) character

valueMode

The valueMode attribute allows you to define a format of a returned value (with a mask or not). This attribute can take two values:

  • clear - sets by default. For the example above, the returned value will be 9967467927.

  • masked - for the example above, the returned value will be 996-746-79-27.

Events and Handlers

To generate a handler stub in Jmix Studio, select the component in the screen descriptor XML or in the Jmix UI hierarchy panel and use the Handlers tab of the Jmix UI inspector panel.

Alternatively, you can use the Generate Handler button in the top panel of the screen controller.

ContextHelpIconClickEvent

EnterPressEvent

Validator

See Validator.

ValueChangeEvent

MaskedField XML Attributes

You can view and edit attributes applicable to the component using the Jmix UI inspector panel of the Studio’s Screen Designer.

MaskedField XML Element