Input masks

Description

Input mask provide the possibility to set a pattern or a template for an input data. It is used to facilitate the processing of values that have a fixed pattern, for example, telephone numbers. Input masks allow users to enter a predefined format in an attribute.

The "mask" field in meta view

Example

{
  "tabs": [
    {
      "caption": "Информационная система",
      "fullFields": [
        {
          "caption": "Уникальный идентификационный номер ОУ",
          "type": 1,
          "property": "OuId",
          "size": 2,
          "maskName": null,
          "mask": null,

At the moment, it is possible to set a mask as a string or an object in the "mask" field.

Default masks

Default masks can be redefined in the extensions:

  • 9 — number
  • a — letter
  • A — uppercase letter
    • — number or letter

Mask types

Static masks

You can predefine the static masks. But they can not be modified while you type.

"mask": "aa-9999",
"mask": {"mask": "aa-9999"},

Optional masks

Optional masks allow making some part of the mask optional for input. In square brackets [] the optional part of the input is specified.

"mask": {"mask": "(99) 9999[9]-9999"},

Dynamic masks

Dynamic masks can be modified while typing. In braces {} the dynamic part of the input is set. It applies to the expression before the braces:

  • {n} - n repetitions
  • {n,m} - from n to m repetitions
  • {+} - from 1 and more repetitions
  • {*} - from 0 and more repetitions
"mask": {"mask": "aa-9{1,4}"},

Generated masks

The syntax of the Generated masks is similar to the OR expression. The mask can be one of three variants, specified in the generator. Use | to determine the generator.

"mask": {"mask": "(aaa)|(999)"},
"mask": {"mask": "(aaa|999|9AA)"},

KeepStatic

By default: - null (~false). It is used in combination with generator syntax and leaves the mask static as you type. When an array of masks is specified, keepStatic automatically becomes true, unless it was specified through parameters.

"mask": { "mask": ["+55-99-9999-9999", "+55-99-99999-9999" ], "keepStatic": true },

Result: Enter 1212345123 => as a result we have - +55-12-1234-5123 enter another 4 => as a result we have - +55-12-12345-1234

Additional examples of masks:

“99 99 999999” — series and number of passport

“[+]9 (999) 999-99-99” — mobile phone number

“(999)|(aaa)” - allows to input either three numbers or three characters

Complex masks

Set the complex masks with character validation. Use the inputmask plugin of the 4.0.0 version to determine the valid fields within the definition. Set as an array in field.mask:

field.mask: ["X{1,4}-AA №999999", {definitions: {"X": {validator: "[lLvVcCxX]", cardinality: 1, casing: "upper"}}}]

Where Index 0 is the mask definition, and index 1 is the additional options.

Masks are also used with “regex”.

"mask": {
    "regex": "[A-Za-z]{1,50}"
},

Masks by ID

Use the "maskName" field of the attribute part of the meta view to set the mask from the mask preset. To be realized.