Regular Expression Val problems

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

I'm trying to allow only numeric characters and a decimal point in a
textbox. According to my RE book [0-9\.] should work but it doesn't - it
will only allow numeric characters. Also the standard [A-Za-z0-9] does not
work- it won't allow any letters?

What am I doing wrong?
Thanks,
T
 
Try this one: ^[\d]+\.{1}$

It allows one or more digits followed by exactly one decimal point

I'm trying to allow only numeric characters and a decimal point in a
textbox. According to my RE book [0-9\.] should work but it doesn't - it
will only allow numeric characters. Also the standard [A-Za-z0-9] does not
work- it won't allow any letters?

What am I doing wrong?
Thanks,
T
 
Unfortunitely, that won't allow any digits after the decimal point.

Also, I still don't understand why [0-9\.] won't allow 9.7 and [A-Za-z0-9]
won't allow AbC98. Seems like something is not working right. (or I have a
bad book)
T
 
Tina can you show how you are applying the reg exp in your page.
Try looking at:- http://www.regexlib.com/
You should see more patterns
Patrick



Tina said:
Unfortunitely, that won't allow any digits after the decimal point.

Also, I still don't understand why [0-9\.] won't allow 9.7 and [A-Za-z0-9]
won't allow AbC98. Seems like something is not working right. (or I have a
bad book)
T


Siva M said:
Try this one: ^[\d]+\.{1}$

It allows one or more digits followed by exactly one decimal point

I'm trying to allow only numeric characters and a decimal point in a
textbox. According to my RE book [0-9\.] should work but it doesn't - it
will only allow numeric characters. Also the standard [A-Za-z0-9] does
not
work- it won't allow any letters?

What am I doing wrong?
Thanks,
T
 
I'm using the patterns in the RegularExpressionValidator vs.net tool.

That looks like a very good website. Once I figure out why good patterns
don't always work in the validator tool, I'll be on my way.

thanks,
T
Patrick.O.Ige said:
Tina can you show how you are applying the reg exp in your page.
Try looking at:- http://www.regexlib.com/
You should see more patterns
Patrick



Tina said:
Unfortunitely, that won't allow any digits after the decimal point.

Also, I still don't understand why [0-9\.] won't allow 9.7 and [A-Za-z0-9]
won't allow AbC98. Seems like something is not working right. (or I have a
bad book)
T


Siva M said:
Try this one: ^[\d]+\.{1}$

It allows one or more digits followed by exactly one decimal point

I'm trying to allow only numeric characters and a decimal point in a
textbox. According to my RE book [0-9\.] should work but it doesn't - it
will only allow numeric characters. Also the standard [A-Za-z0-9]
does
not
work- it won't allow any letters?

What am I doing wrong?
Thanks,
T
 
Back
Top