- Angular UI Development with PrimeNG
- Sudheer Jonna Oleg Varaksin
- 151字
- 2021-07-15 17:33:02
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.
推薦閱讀
- 深入理解Bootstrap
- PyQt從入門到精通
- Python Geospatial Development(Second Edition)
- Integrating Facebook iOS SDK with Your Application
- Swift 4從零到精通iOS開發(fā)
- Getting Started with Python and Raspberry Pi
- Clojure for Java Developers
- Learning Ionic
- 算法圖解
- Oracle 12c從入門到精通(視頻教學(xué)超值版)
- MySQL數(shù)據(jù)庫應(yīng)用實戰(zhàn)教程(慕課版)
- Laravel Design Patterns and Best Practices
- Learning NHibernate 4
- 威脅建模:設(shè)計和交付更安全的軟件
- HTML 5與CSS 3權(quán)威指南(第4版·下冊)