validating a textbox

G

Guest

i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only numbers are
allowed in it. in my regularexpressionvalidator control property window, i
couldnt find the right validation expression to use to make it work properly.
thanks in advance.
 
M

Mark Rae

Newbie said:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only numbers
are
allowed in it. in my regularexpressionvalidator control property window, i
couldnt find the right validation expression to use to make it work
properly.
thanks in advance.

bool IsNumeric(string pstrValue)
{
Regex isNumber = new Regex(@"^\d+$");

Match m = isNumber.Match(pstrValue);
return m.Success;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top