Escape Number 9 in p:inputmask

↘锁芯ラ 提交于 2019-12-01 19:06:09

问题


I want to prepend +90 (Turkey's phone code) to every phone numbers a user enters. For that reason I am using a mask like this:

<p:inputMask
    id="homePhone"
    value="#{personController.model.homePhone}"
    mask="+90 (999) 999-9999"
    size="20"
    converter="converterPhone" />

But displays it like this: +_0 (___) ___-____

However, I want it to look like this: +90 (___) ___-____ <!-- pay attention to 9 -->

Is there a way to escape the first 9 like this: mask="+\90 (999) 999-9999"?

Thank you all...


回答1:


Number 9 is used as mask for all the digits, if you want to use 9, change the mask using JavaScript, by redefining x as mask :

$.mask.definitions['9'] = '';
$.mask.definitions['x'] = '[0-9]';

Now you can use x as mask, :

<p:inputMask mask="+90(xxx) xxx-xxxx" id="homePhone"  />


来源:https://stackoverflow.com/questions/39913451/escape-number-9-in-pinputmask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!