views:

273

answers:

1

Hi,

I am new to Flash and AS3.

I have a DataGrid like this

Item     Percentage
A        20%
B        7.5%

The percentage column is editable.

It is working atm, but I am just looking to enhance user interaction, so my questions is:

How do you restrict user input to only 0-9, . and %.
And when they finished editing a cell, add "%" if it is not already there.

Thank you in advance :)

+1  A: 

To restrict the text that the user can type, you can use the restrict property of the TextInput component. It allows you to provide a string of characters that are allowed in the text input. In this case, your string would be 0-9%. I personally, would also restrict the user from typing % and ALWAYS add it automatically.

To add the % at the end, you could listen for the event when the user changes the text (I believe it's the 'change' event) and if the last character is not "%", append the percent sign to the string.

Mims H. Wright