如何验证文本框小数点前1位和小数点后2位? [英] How to validate for a textbox 1 digit before decimal point and two digits after decimal point?
问题描述
我找到了一个来源,前面是6位数,后面是两位数,但我不知道如何更改
我尝试了什么:
< asp:TextBox ID =txtraterunat =serveronkeypress =if(event.keyCode< 48 || event.keyCode> 57 )event.returnValue = FALSE; MaxLength =9>
< asp:RegularExpressionValidator runat =serverID =RegularExpressionValidator1
ValidationExpression =^ ((\d {5})* |([1-9] \d {0,5}))(\。\\\ {0,2})?$
ControlToValidate =txtrateText =输入必须为123456.78格式。
显示=动态/>
ControlToValidate =txtrateText =输入必须是123456.78格式。
显示=动态/>
开发不是一个在互联网上找到并粘贴它的过程进入你的应用程序:你应该考虑它并弄清楚它是如何工作的(或者更好地自己编写)。
在这种情况下,你不需要任何复杂的东西:
^ \\\\\\
会这样做。
I found a source where it is 6 digits before and two after but i do not know how to change
What I have tried:
<asp:TextBox ID="txtrate" runat="server" onkeypress="if(event.keyCode<48 || event.keyCode>57)event.returnValue=false;" MaxLength="9">
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1"
ValidationExpression="^((\d{5})*|([1-9]\d{0,5}))(\.\d{0,2})?$"
ControlToValidate="txtrate" Text="Input must be 123456.78 format."
Display="Dynamic" />
"
ControlToValidate="txtrate" Text="Input must be 123456.78 format."
Display="Dynamic" />
Development isn't a process where you find something on the internet and paste it into your app: you are supposed to think about it and work out how it works (or better write it yourself).
In this case, you don't need anything that complex:
^\d\.\d\d
Will do it.
这篇关于如何验证文本框小数点前1位和小数点后2位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!