gpt4 book ai didi

jsf-2 - 如何将 Primefaces inputMask 限制为仅数字?

转载 作者:行者123 更新时间:2023-12-04 03:27:13 24 4
gpt4 key购买 nike

我要限制p:inputMask到号码 只有 ,我尝试了以下建议的解决方案:

  • How to restrict an input to numbers only with PrimeFaces inputMask element

  • 但他们都没有工作。我尝试了这两种方法:
    <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:



    inputMaskTest.xhtml:
    <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>

    InputMaskView.java:
    @ManagedBean(name = "inputMaskView")
    @ViewScoped
    public class InputMaskView {
    private String number;

    public String getNumber() {
    return number;
    }
    public void setNumber(String number) {
    this.number = number;
    }
    }
  • 另见:http://forum.primefaces.org/viewtopic.php?f=3&t=37665
  • 关于jsf-2 - 如何将 Primefaces inputMask 限制为仅数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27437146/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com