views:

80

answers:

1

hi all, i have a text input box for entering the currency. it shud allow user to enter numbers from [0-9] and a . operator tht i did it.

now it shud allow 1 to 3(1 or 2 or 3) digits before decimal and 2digits after decimal. the range is betweem 0.00 to 999.99 how can i achieve this in flex3. if user entered 3 digits he shud not b able to enter 4th digit instead he has to type . as 4th char. previously i askd few questions in stackoverflow, i immediatley got the answers, who ever answered i m really thankful to them. regards bagi

A: 

I do not know about flex, but my general regular expression approach would be the following:

/^\d{1,3}\.\d{2}$/

You could test for the users input on every keypress to determine if the input is valid, and reset the value to its previous content if this is not the case.

elusive
how to use this expression as i have tested in regular expression explorer, it giving the results wat i expected but how to use it in flex application.....
bagi
I never used flex myself, but you should be able to figure it out using this documentation: http://livedocs.adobe.com/flex/3/html/help.html?content=12_Using_Regular_Expressions_03.html As far as i can see, you can use the `.test()`-method on string objects to check if the regular expression matches.
elusive
thanku for ur help. it worked . i have another expression
bagi
/[0-9]{1,3}\.[0-9]{1,2}/ also works i any one need
bagi