只接受数字,只接受一个小数点 [英] accept only numbers and only one decimal point

查看:52
本文介绍了只接受数字,只接受一个小数点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我希望验证只接受数字,只接受使用任何asp.net验证控件的一个小数。


I want validations accept only numbers and only one decimal using any asp.net validation controls only.

推荐答案

Refer这并学习如何编写正则表达式:

http://gskinner.com/RegExr/?33iav [ ^ ]



这里有些人创建了正则表达式

http://regexlib.com/Search.aspx?k=decimal&c=-1&m=-1&ps=20&AspxAutoDetectCookieSupport=1 [ ^ ]

请参考这个类似的主题好吧

http://stackoverflow.com/questions/308122/simple-regular-expression-for-a-decimal-with-a-precision-of-2 [ ^ ]
Refer this and learn how to write regular expressions:
http://gskinner.com/RegExr/?33iav[^]

Some created regular expressions here
http://regexlib.com/Search.aspx?k=decimal&c=-1&m=-1&ps=20&AspxAutoDetectCookieSupport=1[^]
Refer this similar thread asw well
http://stackoverflow.com/questions/308122/simple-regular-expression-for-a-decimal-with-a-precision-of-2[^]


尝试使用以下表达式的正则表达式验证器



Try a Regular expression validator with the below expression

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="TextBox1"
       ValidationExpression="^\d+(\.\d{1,1})?


runat = server ErrorMessage = < span class =code-keyword> RegularExpressionValidator > < / asp:RegularExpressionValidator >
" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator>


这篇关于只接受数字,只接受一个小数点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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