Decimal digit problem
On Asp.Net, in my textbox, i do not want to enter after zero three 开发者_运维技巧numbers. For example if you enter textbox 0.222 it should be 0.22. After 0.22 you should not enter anything. How can i make this?
Thanks
Use a Masked TextBox.
I think it is better to use an Expression
instead of Masked Textbox
.
With a simple RegularExpressionValidator
you are able to do this, just drag one in your worksheet and then set the TargetControl
of it to your Textbox, then set its value to ^\ddd
.
Using javascript add an attribute onkeyup='formatNumber(this)' on the tag.
function formatNumber(textBox) {
var current = textBox.value;
var output = "";
//find '000' in current
//delete what you want
textBox.value = output;
}
精彩评论