I have a textbox that I created using .NET..

By using that textbox, the user only can key in numeric. But not start with 0. start with 1-9. after the user key in the 1-9 at the first character, the user can key in 0.

Regex reg = null;
reg = new System.Text.RegularExpressions.Regex("^[1-9][0-9]*$")
return reg.IsMatch(str);

That is my regex expression. By using that i can't key in 1-9. but only 0 and alphabet. But if i using ^[1-9] I can key in numeric, but can't key in the 0.

I already tried all the answer that all of you suggest. But still can't work. It's not like i dont read all of your answer.

here is the picture..

enter image description here

I want to validate at the first time, the user only can key in numeric, but start with value that is not 0 or alphabet but 1-9. After the first character, user may only key in 0-9.

i do use Int.TryParse, but i use that after i hit a button to process.

reg = new System.Text.RegularExpressions.Regex("^[^0-9]");

that regex accept only numeric from 0 to 9.

reg = new System.Text.RegularExpressions.Regex("^[^1-9]");

that regex accept only numeric from 1 to 9.

How can i add more expression to regex for the second character until the rest that only accept numeric 0-9?

By the way, i don't care about 0.99 because in here, the price is fix. not with 0.99 or 0.123..

Any others way to do it? thanks.

Edit
Report