强制ASP.NET文本框与$符号显示货币 [英] Force ASP.NET textbox to display currency with $ sign
问题描述
有没有办法得到一个ASP.NET文本框只接受货币值,而当控制验证,先插入一个$符号?
Is there a way to get an ASP.NET textbox to accept only currency values, and when the control is validated, insert a $ sign beforehand?
例如:
10.23成为$ 10.23
$ 1.45 $停留
10.A引发错误,由于不是一个有效的数字,以
10.23 becomes $10.23
$1.45 stays $1.45
10.a raises error due to not being a valid number
我有一个验证的数量RegularEx pressionValidator是有效的,但我不知道如何强制$符号到文字。我怀疑的JavaScript可能会奏效,但想知道是否有另一种方式来做到这一点。
I have a RegularExpressionValidator that is verifying the number is valid, but I don't know how to force the $ sign into the text. I suspect JavaScript might work, but was wondering if there was another way to do this.
推荐答案
在ASP.NET MaskedEdit 从 AJAX控件工具包控制可以完成你的要求了。
The ASP.NET MaskedEdit control from the AJAX Control Toolkit can accomplish what you're asking for.
这篇关于强制ASP.NET文本框与$符号显示货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!