不允许 h:inputText 中的负数

Disallow negative numbers in h:inputText

如果输入 -ve 值,我想应用验证。我可以使用以下标签和属性来做到这一点:

<h:inputText id="MyPrice" validatorMessage="negatieve prijs niet toegestaan">

    <f:convertNumber type="number"
                     groupingUsed="true"
                     locale="nl_NL"
                     maxFractionDigits="2"
                     minFractionDigits="2"/>

    <f:validateLongRange minimum="0"/>
<h:inputText>

<rich:message for="MyPrice"/>

使用它,我可以使用以下输入成功验证 -ve 和 +ve 值: 适合:[我遵循荷兰数字系统,其中“,”被视为“。”例如,要写 0.55,我们需要写 0,55),这是我使用 <f:convertNumber>.

完成的
100
10.25
10,98
-100
-10.25
-10,98
0.55

但是当我输入-0,55 时,验证不起作用。当我输入以 -0.xx.

开头的 -ve 值时,请提供验证解决方案

您的验证器不正确 - 价格不是 Long。将其更改为

<f:validateDoubleRange minimum="0" />