It sounds like you want to validate decimal values with the thousand's
separator (1,200,300.45) and discovered that CompareValidator
(Operator=DataTypeCheck, Type=Decimal) doesn't handle the decimal places.
The regular expression has its faults. Mostly, it cannot really determine if
a valid number is entered. It just looks at string patterns. The
CompareValidator actually parses the text and converts it into a decimal
value. If that conversion fails, it reports an error. By converting it to
decimal, it also allows comparisons like comparing to another number as
offered by the RangeValidator and CompareValidator.
Considering this, you may want to use a technique that converts to a decimal
value. Here are some ideas:
1. Use a CustomValidator and implement server side validation that uses
..net's Decimal.Parse() method. Going further, write a client-side evaluation
function that strips out all commas then uses javascript's parseFloat()
function:
var vVal = parseFloat(vText);
if (isNaN(vVal))
// its an error
2. My replacement to Microsoft's validators, Professional Validation And
More, automatically supports thousands separators in its own versions of
RangeValidator and CompareValidator. It handles client side validation
properly and works on many more browsers.
(
http://www.peterblum.com/vam/home.aspx) It also provides a DecimalTextBox
and CurrencyTextBox that filter keystrokes and reformats, inserting
thousands separators if you like.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
"Robert Scheer" <rb******@my-deja.com> wrote in message
news:cf**************************@posting.google.c om...
Hi.
I have a regularexpression validator control on a page. This regular
expression validates a textbox to accept only numbers and commas:
validationexpression="[\d,]*"
I am trying to modify this expression to not allow commas at the
beginning and at the end of the expression without success. It needs
to allow commas only between the numbers. How can I do that?
Thanks,
Robert Scheer