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

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.
主站蜘蛛池模板: 紫阳县| 宽城| 正阳县| 会同县| 莆田市| 手机| 克什克腾旗| 景泰县| 横峰县| 株洲县| 和田市| 乌拉特中旗| 三原县| 翁牛特旗| 南宁市| 皮山县| 榆中县| 格尔木市| 沙湾县| 成安县| 舒兰市| 嘉峪关市| 临湘市| 武城县| 全椒县| 吉林市| 新疆| 广丰县| 右玉县| 赤城县| 巴青县| 获嘉县| 长子县| 宜兰县| 会东县| 丰城市| 金沙县| 温州市| 砚山县| 乐安县| 卓尼县|