如何验证文本框只包含mvc中的数字,逗号和点 [英] how to validate textbox to include only numbers, comma and dot in mvc

查看:98
本文介绍了如何验证文本框只包含mvc中的数字,逗号和点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何验证文本框只包含数字,逗号和点

how to validate textbox to include only numbers, comma and dot

推荐答案

使用正则表达式:

基本:

^ [\\\\。,] +
Use a regex:
Basic:
^[\d\.,]+


更好(对于欧洲数字,如1,234,567.0022),请参见此处: http://stackoverflow.com/questions/5917082/regular-expression-to -match-numbers-with-or-without-commas-and-decimals-in-text [ ^ ]
Better (for european numbers such as 1,234,567.0022), see here: http://stackoverflow.com/questions/5917082/regular-expression-to-match-numbers-with-or-without-commas-and-decimals-in-text[^]


这篇关于如何验证文本框只包含mvc中的数字,逗号和点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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