p:keyFilter在Firefox中无法按预期工作 [英] p:keyFilter not working as expected in Firefox

查看:47
本文介绍了p:keyFilter在Firefox中无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以为p输入文本输入数字和特殊字符.

I'm able to enter both the digits and special characters for the p input text.

如何限制只能接受数字的字段?在所有浏览器中?

How to restrict the field that can accept only digits? in all the browsers?

<p:message for="longitude" display="text"><p:autoUpdate/></p:message>
<p:inputText id="longitude" maxlength="18" style="width: 50%;" value="#{areaMB.longitude}">
<p:keyFilter regEx="/[0-9]/i" />
</p:inputText>

浏览器Chrome版本81.0.4044.113(64位)-只能在该字段中输入数字
浏览器IE版本11.0.9600-只有数字可以在字段中输入

Browser Chrome Version 81.0.4044.113 (64-bit) - Only Digits are being able to enter in the field
Browser IE Version 11.0.9600 - Only Digits are being able to enter in the field

问题 但是通过Fire Fox

Problem But through Fire Fox

Browser Fire Fox 75.0(64位)-可以在字段中输入数字和特殊字符/

Browser Fire Fox 75.0 (64-bit) - Digits and Special characters are being able to enter in the field /

如何限制只能接受数字的字段?在所有浏览器中?

How to restrict the field that can accept only digits? in all the browsers?

问题仅存在于浏览器中Fire Fox,并且大多数用户正在使用此浏览器.

The Issue only exists in the Browser Fire Fox and most of the users are using this browser.

推荐答案

此KeyFilter Firefox问题已在PrimeFaces 8.0中修复: https://github.com/primefaces/primefaces/issues/5110

This KeyFilter Firefox issue was fixed in PrimeFaces 8.0: https://github.com/primefaces/primefaces/issues/5110

如果您确实需要将输入限制为数字,则可以使用p:inputNumber这样.

If you really need to restrict input to digits you can use p:inputNumber like this.

<p:inputNumber id="longitude" 
               maxlength="18" 
               style="width: 50%;" 
               value="#{areaMB.longitude}" 
               decimalPlaces="0"
               minValue="0" />

如果要允许负数,请删除minValue.

Remove minValue if you want to allow negative numbers.

这篇关于p:keyFilter在Firefox中无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆