Blank space should not be allowed in Flex Input field... one is fine... but not more than one...
+1
A:
Try something like this.
var s:String = "I am good going"; // or input.text
Alert.show(s.split(" ").length.toString());
In this s.split(" ").length - 1 is the number of spaces
Umesh
2009-12-22 07:20:34
I need Regular expressions...
2009-12-22 07:31:07
Why is there a need for regular expression? The're multiple roads to rome.
PoweRoy
2009-12-22 08:24:05
A:
If you want a Regex, this will match any string which contains more than one space:
/.* .* /
David Wolever
2009-12-22 07:52:17
That doesn't work because the `restrict` property doesn't accept regular expressions.
David Wolever
2009-12-22 08:15:47
+1
A:
Better solutions would be to catch the change event, then cancel it if it would add a second space, or use a validator:
<mx:RegExpValidator
source="{oneSpace}" property="text"
expression=".* .* " />
<mx:TextInput id="oneSpace" />
See: http://livedocs.adobe.com/flex/3/html/help.html?content=validators%5F7.html and http://livedocs.adobe.com/flex/3/langref/mx/validators/RegExpValidator.html
David Wolever
2009-12-22 08:21:03