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 whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 
G

Guest

it's not allowing whole nos.

Brendan Grant said:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan


Newbie said:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 
G

Guest

Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan


Newbie said:
it's not allowing whole nos.

Brendan Grant said:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan


Newbie said:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 
G

Guest

it's not allowing x.xx such as 5.25

Brendan Grant said:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan


Newbie said:
it's not allowing whole nos.

Brendan Grant said:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan


:

i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 
G

Guest

I apologize again, it seems that I missed a character when updating the regex
string for you, namely a *, so we go from:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$
to
^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)|(([-]|[0-9])[0-9]*)+$

Brendan


Newbie said:
it's not allowing x.xx such as 5.25

Brendan Grant said:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan


Newbie said:
it's not allowing whole nos.

:

Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan


:

i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 
G

Guest

its now working:

^([$]?\d+(\.\d{2})?$)|([$]?\d+(\.\d{1})?$)

thanks

Brendan Grant said:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan


Newbie said:
it's not allowing whole nos.

Brendan Grant said:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan


:

i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.
 

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