如何验证文本框小数点前1位和小数点后2位?

编程入门 行业动态 更新时间:2024-10-20 05:41:17
本文介绍了如何验证文本框小数点前1位和小数点后2位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我找到了一个来源,前面是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位?

本文发布于:2023-07-06 08:00:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047614.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小数点   文本框

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!