如何验证在deciaml点后应该取一位三位数的文本框 [英] how to validate a textbox which should take one 3 digits after deciaml point

查看:88
本文介绍了如何验证在deciaml点后应该取一位三位数的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在我的Web应用程序中,我有一些字段,分别是长度,宽度,高度,距离.
在这里,我的要求是从用户那里获取此字段的输入日期时,我需要检查小数点后的位数是多少,例如233.345.

如果用户输入的值如3443.83839,则应通过错误消息向用户发送,小数点后只能输入3位数字.


我如何使用customvalidator实现此功能,请给我编码并建议我得到它.

谢谢大家

uday

Hi all,


In my web application i have some fields that are Lenght, Breadth,Height, Distance.
Here my requirement is while get input date for this fields from user i need to check how many digits are entered after decimal point value, for example 233.345.

if user enter value like 3443.83839 it should through error msg to user that after decimal point only 3 digits should be enter.


How can i achive this with customvalidator, please give me the coding and suggest me to get it.

Thanks all

uday

推荐答案

由于文本框仅返回一个字符串,因此请使用IndexOf方法为您提供小数点的位置,并将其与Text的Length属性进行比较.
Since the textbox only returns a string, use the IndexOf method to give you the position of the decimal point, and compare it against the Length of the Text property.


您好udaysimha,

尝试为此使用reg-ex.

试试这个:

^ [0-9]([\.\,] [0-9] {1,3})?
Hi udaysimha,

try using reg-ex for it.

Try this:

^[0-9]([\.\,][0-9]{1,3})?




希望对您有所帮助:)

问候,
爱德华


Hope it helps :)

Regards,
Eduard


这篇关于如何验证在deciaml点后应该取一位三位数的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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