views:

47

answers:

1

Hi,

I'm looking for a regex or a way to format the NumberValidator so that only decimal places are allowed.

The domain="real" allows you to put integer values, but I need to force the user to but in 2.0 if they want an integer.

This is because they pass through a Castor mapping file, it complains if it gets an integer when it expects a decimal.

I dont want to restrict the number of decimal places, just insist that there must be a point, and a number after it.

Any help would be much appreciated.

A: 

I don't know Flex, but if I undrestand correctly, you're probably looking for something like /^-?\d+\.\d+$/. Or /^-?\d*\.\d+$/ if .1 is valid.

Oblio
Or `/^-?(\d+\.\d*|\.\d+)$/` if `1.` is also valid.
Gumbo
Those regexes just seem to prevent me from typing ANY characters :-(
Try without the slashes i.e. <code>^-?\d+.\d+$</code>
Oblio
I think a RegexValidator is probably more appropriate for me than a number validator. At least now I can type in the input boxes. On the down side, noneofthe above seem to match ANY decimal or number format??So I've tried them with the likes of 0.1 and 2.1, and even just left it as a number. no joy.
Using the above regexes in the regex validator here: http://livedocs.adobe.com/flex/3/html/help.html?content=validators_7.htmlI actuall get the right results. Not sure why is not working in my App. But it looks like the problem is not with your expression. Thanks for the help.