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

Making a part of the mask optional

Till now, all the examples of input masks have shown that all the characters in a mask are mandatory. It is also possible that you can make a part of the mask optional with the use of the question mark (?) character. Anything listed after the question mark within a mask definition will be treated as an optional input. A common use case is displaying the phone number with an optional extension number, as follows:

<span>Phone Ext</span>
<p-inputMask mask="(999) 999-9999? x99999" [(ngModel)]="optional"
name="optionalmask" placeholder="(999) 999-9999? x99999">
</p-inputMask>

Once the user finishes the input by reaching the question mark character and blurs the component, the rest of the validation will be skipped. That is, the input up to that part won't be erased. For example, phone number inputs, such as (666) 234-5678 and (666) 234-5678? x1230 will be valid inputs for the mask's optional case.

The complete demo application with instructions is available on GitHub at
https://github.com/ova2/angular-development-with-primeng/tree/master/chapter3/inputmask.
主站蜘蛛池模板: 常山县| 马鞍山市| 辽源市| 秭归县| 海宁市| 青铜峡市| 乳山市| 泰和县| 囊谦县| 恩施市| 抚远县| 巧家县| 松阳县| 宁陕县| 介休市| 萨迦县| 溧阳市| 北碚区| 农安县| 灵宝市| 洪雅县| 定襄县| 柞水县| 杭锦后旗| 威远县| 泸水县| 嘉黎县| 安宁市| 华坪县| 大洼县| 新巴尔虎左旗| 漯河市| 闵行区| 海城市| 潞西市| 文登市| 乌拉特后旗| 香港 | 郧西县| 缙云县| 尖扎县|