validating a textbox

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
Back
Top