只接受数字,只接受一个小数点

问题描述:



我希望验证只接受数字,只接受使用任何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 = RegularExpressionValidator > < / asp:RegularExpressionValidator >
" runat="server" ErrorMessage="RegularExpressionValidator"></asp:RegularExpressionValidator>