i want to apply masking over the textinput that need to get SSN from user so How apply SSN masking over text input in Flash Builder 4?
The most elegant solution in the long run would be to create a custom component, but it could also be done within an existing TextInput. Give the TextInput a change event that does the following:
var s:String=textInput.text.replace(/[^0-9]/g,"");
textInput.text = s.substring(0,3) +
(s.length>3?"-"+s.substring(3,5)+
(s.length>5?"-"+s.substring(5,9):""):"");
textInput.selectRange(textInput.text.length,textInput.text.length);
This will mask the characters:
txtInput.displayAsPassword = true;
<s:TextInput displayAsPassword="true" restrict="0-9" maxChars="9"/> will cause the text to be shown as asterisks when the user is entering it, and will also prevent them from entering more than 9 characters, or any characters that are not numeric, both of which are requirements of SSNs.
Related
So, when I'm building an application in Flash and Actionscript 3.0 I create a sharedobject.data and I have an input field, the sharedobject is equal to the input field.But it's only restricted to numbers, but when the input is put in the number is thought to be text.. rather than an actual number (eg. "1" instead of just 1) is there anyway that I can make an input field into something like a number field?
Have you tried:
var variable:Number;
variable= Number(input_txt.text);
In my Flex application, I have a TextInput box that a user may enter a Number. It comes in as a String, then passes through a NumberFormatter. The result then gets displayed in the TextInput box. This works fine for small numbers.
Large numbers have a problem. For example, if the user enters 100e30 (which is scientific notation for 1x10^32), the TextInput displays:
100000000000000000000000000000000
when what I really want to display is
1.0E32
This is how it appears (and is stored) internally in Flash Builder, for example, as viewed using the debugger.
Is there any simple routine in AS3/mxml that can output scientific notation to a TextInput control?
var n:Number = 10000000000;
trace(n.toExponential(1));
Output :
1.0e+10
To set it to the text input :
textInput.text = n.toExponential(1);
I am making something in Actionscript 3, where people can modify a piece of text, within a TextArea.
Now, it's easy to get the typed character, but using event.getChar.
But, I would also like to know where the character was typed: the (text)cursor position.
I've read about that it's easy to do with a TextField, however, I want to use a TextArea for a few reasons:
I've read about it being possible with a TextField, but I'm not sure how I would make that into an input field...
Also, the TextArea is recommended for multiline text.
If I could hack a TextField to behave like a TextArea, I'm fine with that.
So, my question:
How can I get the position of the cursor in a TextArea?
or
How can I make a TextField behave like a TextArea?
EDIT: I managed to make an input TextField, but the caretIndex returns xyz coordinates, pretty useless for text editing/comparing... Any suggestions on that?
you can see which letter was clicked in a textfield by doing the following:
var tf:TextField;
var clicked_on_index:int = tf.getCharIndexAtPoint(tf.mouseX, tf.mouseY);//find index of char clicked on in string
var clicked_on_char:String = tf.text.substr( clicked_on_index, 1 );//find char clicked on from textfield
or if you just want to know the position of the last character entered:
var tf:TextField;
tf.addEventListener(Event.CHANGE,function(event:Event):void{
var newCharacterPosition:int=tf.caretIndex;
var totalCharacters:int=tf.text.length;
});
I can type text into a field using WebElement.sendKeys() but editing doesn't work: I can neither move the cursor nor delete the last character that I typed with e.sendKeys( Keys.BACK_SPACE )
How do I modify the value of a text field in Selenium 2 (WebDriver)?
You can definitely do that by either of the two methods. I have tried and it works.
e.click() # Positions the cursor at the end of the string
e.sendKeys(Keys.BACK_SPACE )
Or you could simply clear the text, and start over again:
e.clear()
e.sendKeys("What you want to send")
I found this solution that seems to work pretty well. It basically clicks on the text field WebElement, then sends Ctrl-End to put the cursor at the end of the text. Then sends the string that I had previously initialized.
(quickReplyTextArea is a text field WebElement that I have previous found, as is postQuickReplyButton (button instead of text field, obviously). replyText is a String that I initialized earlier)
quickReplyTextArea.click();
quickReplyTextArea.sendKeys(Keys.chord(Keys.CONTROL, Keys.END));
quickReplyTextArea.sendKeys(replyText);
postQuickReplyButton.click();
You can try clicking first into that text box, and use sendKeys() afterwards.
I need to restrict my users to input only dates with a custom format. I want to have something like this example in JQuery: http://www.youtube.com/watch?v=BMaTiGKykl8&feature=player_embedded
How can i archieved this in AS3?
You'll have to catch the KeyPressed event on the TextField. Check if the key pressed is OK at the specified position, if yes, do nothing, if not, cancel the event (Event.cancel = true).
Alternatively (for more features, like these auto added slashes) you can ALWAYS cancel the Event, and use the TextField's selection together with a String and some checking to always make a new version of the TextField's text.
Why not use a DateField and format the data as you see fit?
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/DateField.html?filter_flex=4.1&filter_flashplayer=10.1&filter_air=2