作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我要限制p:inputMask
到号码 只有 ,我尝试了以下建议的解决方案:
<p:inputMask id="userNo" maxlength="2" mask="9?9999" />
<p:inputMask id="userNo" maxlength="2" >
<pe:keyFilter regEx="/[0-9_]/i"/>
</p:inputMask>
最佳答案
我认为这种方法是正确的,但我注意到您没有输入 value
inputMask
上的属性.
你试着穿上它吗?
Edit: These solutions works:
<h3>Input Mask:</h3>
<h:form id="form">
<p:outputLabel value="Input Mask only number " for="userNo1" />
<p:inputMask id="userNo1" maxlength="2" mask="9?9999" value="#{inputMaskView.number}"/>
<p:outputLabel value="Input Mask only Number Primeface Ext " for="userNo2" />
<p:inputMask id="userNo2" maxlength="2" value="#{inputMaskView.number}">
<pe:keyFilter regEx="/[0-9_]/i" />
</p:inputMask>
</h:form>
@ManagedBean(name = "inputMaskView")
@ViewScoped
public class InputMaskView {
private String number;
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
}
关于jsf-2 - 如何将 Primefaces inputMask 限制为仅数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27437146/
我是一名优秀的程序员,十分优秀!