Google Answers Logo
View Question
 
Q: Flash MX Actionscript - TextField focus/cursor problem ( No Answer,   0 Comments )
Question  
Subject: Flash MX Actionscript - TextField focus/cursor problem
Category: Computers > Programming
Asked by: g8z-ga
List Price: $10.00
Posted: 19 Jun 2003 13:52 PDT
Expires: 19 Jul 2003 13:52 PDT
Question ID: 219384
Hello,

I have a Macromedia Flash MX-based form, and I want to validate the
input to a field. If the validation fails, the invalid text should
become highlighted, and the cursor should be placed in the erroneous
field until the user corrects it.

For example, in the code below, when "first" is not equal to "abc",
then the system should a) select the content of the 'first' text
field, and b) insert the cursor into the 'first' field so that the
user can start typing to correct the invalid input.

Currently, this code WILL do the selection of "first" correctly, but
it will not do the cursor placement correctly. You can see this effect
by going to:

http://www.tufat.com/test.html

You will see a blue textbox and a black textbox. In the black textbox,
type any random string of characters. Then, click the mouse into the
blue textbox. If the contents of the black textbox area not equal to
"abc", then the contents of the black textbox become highlighted, as
they should. However, the *cursor* remains in the blue textbox! I want
the cursor to jump back to the black textbox.

Here's the code.....

createTextField( "first", 2, 10, 10, 200, 20 );
createTextField( "second", 3, 10, 40, 200, 20 );

first.border = 1;
first.borderColor = 0x000000;
first.type = "input";

second.border = 1;
second.borderColor = 0x0000FF;
second.type = "input";

first.onKillFocus = function() {
if ( first.text != "abc" ) {
Selection.setFocus( first ); 
}
return;
};

Thanks,
Darren

ps. I posted the same question on a FlashKit.com bulletin board, which
you can read here:

http://www.flashkit.com/board/showthread.php?s=a18b3d472ac77d5ed548a6cba480bc4d&threadid=464285

The person who replied to my query didn't really solve my problem,
though.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy