Tuesday, March 30, 2010

Finding Keyboard.ENTER in text field

Hi guys,

I'm having troubles with textfields. I have numerous textfields on the stage but it's happening to all so I'll just describe one.

Lets say I have an input textField named that I restrict to allow only numbers 0-9:

inputText_txt.restrict=''0-9'';

That all works fine.

THE PROBLEM:

When I select the field (which initial value is set to ''0'') and hit delete it clears the field and if I press ENTER it will accept that as a value.

I've tried this code to say if it equals '' '' then to not save the file....


if(inputText_txt.text=='' ''){

trace(''.''+inputText+''.'');

}


Also tried:

if(inputText_txt.text==Keyboard.ENTER){

trace('' Trying Keyboard.Enter: .''+inputText+''.'');

}

trace(''.''+inputText+''.'');

It only traces the last trace, shown below: How can I get it to not allow the extra spacing?

.

.

it should trace:

..

any ideas?

thanks

Finding Keyboard.ENTER in text field

Make your TextField single line, so it doesn't accept carriage returns:

inputText_txt.multiline=false;

Finding Keyboard.ENTER in text field

Genius, I tell you... simply genius.... thank you I can't believe it was so stinkin' simple?

You're welcome!

No comments:

Post a Comment