Restricting TextInput value to 5 decimal points

445 views
Skip to first unread message

Amruta Kulkarni

unread,
Sep 7, 2011, 10:14:54 AM9/7/11
to flex_...@googlegroups.com

Hi All,
 
I am working on a flex application which has requirement to restrict user to enter the numbers with 5 decimal places only.I tried the 'restrict' property of TextInput control.Here is the code snippet that I tried:
 

<mx:TextInput id="txtValue" restrict="[0-9]*\.?[0-9]{0,5}" />

 but this is not working.Can anyone help me out on this?Its very urgent.

 

Thanks
-Amruta Kulkarni


naveen SR

unread,
Sep 8, 2011, 10:22:21 AM9/8/11
to flex_...@googlegroups.com
Hello Amrutha,

If my understanding from ur below snippet is correct your trying to use the text input only for decimal places, if yes use maxchars to 5 and restrict from 0 to 9.

If your requirement is to have the same text input for both the integer and decimal ,  build simple custom component extending textinput to do this validation.

Cheers,
Naveen


--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

kiran reddy

unread,
Sep 10, 2011, 3:26:28 AM9/10/11
to flex_...@googlegroups.com, amruta.k...@gmail.com
Hi Amrutha

You can use Number Validator

Look following code

Regards
Kiran Reddy


<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
</fx:Script>
<fx:Declarations>
<mx:NumberValidator id="numV" source="{sampleText}" property="text"
trigger="{myButton}" triggerEvent="click" domain="real" precision="5"
precisionError="Decimal Should Not be morethan 5"/>
</fx:Declarations>
<s:layout>
<s:VerticalLayout/>
</s:layout>


<mx:TextInput id="sampleText"/>
<mx:Button id="myButton" label="Validate"/>

</s:Application>

Rashmi Mirajkar

unread,
Sep 10, 2011, 8:49:40 AM9/10/11
to flex_...@googlegroups.com

Hi
You need
to use max chars property as 5 and  0-9 in restrict property then i think solves your problem

Amruta Kulkarni

unread,
Sep 11, 2011, 8:42:36 AM9/11/11
to flex_...@googlegroups.com
Thanks all for your suggestions & solutions.I solved the problem using regular expression validator.

Biswajit Mishra

unread,
Feb 16, 2015, 8:21:51 AM2/16/15
to flex_...@googlegroups.com
Hi All,
Can u please help me out in the same.
I have a similar case where i need to create a regular expression where there is a number with three decimals followed by forward slash then again a number.

eg. 12.123/12/34.1234

It should trim number 4 from the decimal or else show an alert message entry is wrong.

Naveen Malhotra

unread,
Feb 17, 2015, 3:37:48 AM2/17/15
to flex_...@googlegroups.com
You can try using MaskedTextInput as given below

<ns:MaskedTextInput maskText="##.###/##/##.####"/>

Then you can write your logic to split the text based on the delimiter.

Thanks,
Naveen


--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flex_india+...@googlegroups.com.

To post to this group, send email to flex_...@googlegroups.com.



--
Thanks,
Naveen Malhotra

yasala...@gmail.com

unread,
Feb 17, 2015, 5:18:06 AM2/17/15
to flex_...@googlegroups.com
Do we have any flex group Id in Usa ?
My friend is looking for Adobe flex position in Usa so please let us know if any .

Reply all
Reply to author
Forward
0 new messages