Home All Groups Group Topic Archive Search About

Regular Expression Validator question

Author
24 Dec 2006 2:37 PM
curious
I am using a RegularExpressionValidator to validate a TextBox. I use
"^[\+|-]?[0-9]+(\.[0-9]*)?$" to check for a real number. The control works
fine as long as the user enters something in the TextBox; it does not work if
the user leaves the TextBox blank. Is there a bug in the implementation of
the  RegularExpressionValidator? My regluar expression should also catch no
entry by the user.

Thanks.
--
ASP.NET fan.

Author
25 Dec 2006 8:53 AM
marss
curious wrote:
> I am using a RegularExpressionValidator to validate a TextBox. I use
> "^[\+|-]?[0-9]+(\.[0-9]*)?$" to check for a real number. The control works
> fine as long as the user enters something in the TextBox; it does not work if
> the user leaves the TextBox blank. Is there a bug in the implementation of
> the  RegularExpressionValidator? My regluar expression should also catch no
> entry by the user.
>
> Thanks.
> --
> ASP.NET fan.

MSDN: "Validation succeeds if the input control is empty. If a value is
required for the associated input control, use a RequiredFieldValidator
control in addition to the RegularExpressionValidator control."