c#:在文本框中允许小数点前5位数 [英] c# : Allow 5 digit before decimal point in text box

查看:156
本文介绍了c#:在文本框中允许小数点前5位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

如何在文本框中小数点前允许5位数。

hi friends
How can I Allow 5 digit before decimal point in text box.

推荐答案

说实话,我不会'吨。您可以通过处理TextChanged和KeyPress事件并验证这种方式,或者通过处理Validate事件来实现它,但是...

我将使用NumericUpDown控件,并设置最大值99999.9999和最小值0.它更容易,更灵活,它允许用户输入尽可能多的前导零,而不允许他输入字母字符。
To be honest, I wouldn't. You can do it, by either handling the TextChanged and KeyPress events and validating that way, or by handling the Validate event but...
I'd use a NumericUpDown control instead, and set a maximum of 99999.9999 and a minimum of 0. It's easier, it's more flexible, and it allows the user to enter as many leading zeros as he feels like, without allowing him to enter alpha characters.


HI

你可以在文本框中使用正则表达式



< asp:regularexpressionvalidator id =rgxcontroltovalidate =txtControlrunat =server xmlns:asp =#unknown>

ErrorMessage =*Display =DynamicValidationExpression =^ [0-9] \d {0,5}(\。 \d {1,2})?%?
HI
You can use regular expression for textbox

<asp:regularexpressionvalidator id="rgx" controltovalidate="txtControl" runat="server" xmlns:asp="#unknown">
ErrorMessage="*" Display="Dynamic" ValidationExpression="^[0-9]\d{0,5}(\.\d{1,2})?%?


>





使用这个

它会对你有帮助。
">


use this
it will help you.


这篇关于c#:在文本框中允许小数点前5位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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