[英]Regular Expression to allow only 0-9 digits only (Not even '.' [Dot]) in JSP using javascript
Could anyone please provide me with a regular expression to allow only digits (0-9) excluding even '.' 谁能为我提供一个正则表达式,以允许仅输入数字(0-9),甚至不包括“。”。 (decimal point) in a textbox in JSP using javascript. (小数点)使用JavaScript在JSP中的文本框中。 I would be using it to replace the resricted characters with '' (empty string). 我会用它用''(空字符串)替换限制的字符。
I tried few but they are not restricitng the DOT. 我尝试了几次,但他们没有限制DOT。
Thanks in advance 提前致谢
正则表达式模式为:
/^[0-9]+$/
I would use the class \\d
, it includes only digits. 我将使用类\\d
,它仅包含数字。 If you want to replace all non-digits you would need to replace \\D+
with ""
. 如果要替换所有非数字,则需要将\\D+
替换为""
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.