官术网_书友最值得收藏!

Mask format options

The mask attribute is mandatory to use for the input mask. The component not only allows the number type, but it also supports alphabetic and alphanumeric characters, so the mask format can be a combination of the following built-in definitions:

  • a: Alphabetic character (A-Z,a-z)
  • 9: Numeric character (0-9)
  • *: Alphanumeric character (A-Z,a-z,0-9)

Let's take an example where we can show the input mask with different mask options based on a radio button selection, as follows:

<div>
<div id="phoneformat" *ngIf="format == 'Option1'">
<span>Phone:</span>
<p-inputMask mask="(999) 999-9999" [(ngModel)]="phone"
placeholder="(999) 999-9999" name="phone">
</p-inputMask>
</div>
<div id="dateformat" *ngIf="format == 'Option2'">
<span>Date:</span>
<p-inputMask mask="99/99/9999" [(ngModel)]="date"
placeholder="99/99/9999" name="date">
</p-inputMask>
</div>
<div id="serialformat" *ngIf="format == 'Option3'">
<span>Serial Number:</span>
<p-inputMask mask="a*-999-a999" [(ngModel)]="serial"
placeholder="a*-999-a999" name="serial">
</p-inputMask>
</div>
</div>

As per the preceding example, only one input element will be displayed with the defined mask. The following screenshot shows a snapshot result of the mask format for a date:

The unmask attribute can be used to control masked or unmasked output for the value bounded. For instance, it is useful if ngModel sets either a raw unmasked value or a formatted mask value to the component's bound value.
主站蜘蛛池模板: 灵璧县| 聂荣县| 榆中县| 滨海县| 余江县| 宝清县| 新泰市| 霞浦县| 上饶市| 彭泽县| 永安市| 象山县| 道真| 犍为县| 奉化市| 砚山县| 灵石县| 平舆县| 白银市| 闽清县| 神农架林区| 庆元县| 丹巴县| 永吉县| 上高县| 老河口市| 增城市| 凤翔县| 区。| 康保县| 肇源县| 邹城市| 宁远县| 耒阳市| 石城县| 冀州市| 珲春市| 乐平市| 黄浦区| 江孜县| 黎平县|