- Angular UI Development with PrimeNG
- Sudheer Jonna Oleg Varaksin
- 153字
- 2021-07-15 17:33:03
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.
https://github.com/ova2/angular-development-with-primeng/tree/master/chapter3/inputmask.
推薦閱讀
- GitLab Cookbook
- 測(cè)試驅(qū)動(dòng)開(kāi)發(fā):入門(mén)、實(shí)戰(zhàn)與進(jìn)階
- Learning Apex Programming
- PHP+MySQL網(wǎng)站開(kāi)發(fā)技術(shù)項(xiàng)目式教程(第2版)
- Instant Typeahead.js
- Git高手之路
- Functional Programming in JavaScript
- Learn Swift by Building Applications
- Mastering Unity Shaders and Effects
- CKA/CKAD應(yīng)試教程:從Docker到Kubernetes完全攻略
- Getting Started with LLVM Core Libraries
- Vue.js 2 Web Development Projects
- Java SE實(shí)踐教程
- C指針原理揭秘:基于底層實(shí)現(xiàn)機(jī)制
- MonoTouch應(yīng)用開(kāi)發(fā)實(shí)踐指南:使用C#和.NET開(kāi)發(fā)iOS應(yīng)用