Skip to main content
Inspiring
January 29, 2009
Question

detecting text in text entry

  • January 29, 2009
  • 3 replies
  • 295 views
What would be a good method of detecting the presence of text in a text
entry field?

And if there were only spaces pressed then that would be regarded as an
empty text extry field.

I thought about a textfield listener triggered with onchage which does a
split and join on the space character and then check if the resulting string
length is greater than zero. I think this would work but seems very
inefficient when there are long passages of text.

Any ideas on a better method?

Many thanks

Dave


This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
January 30, 2009
yes.
Inspiring
January 30, 2009
Thanks for the reply

The other idea I had was to start at the beginning of the string and check
each character and if it is a non space then break from the search loop.
That way a few spaces would get thrown out as empty, but I would assume that
some text would be typed fairly early on in the text.

Would that make sense?

"kglad" <webforumsuser@macromedia.com> wrote in message
news:glson1$itn$1@forums.macromedia.com...
> unless someone copies and pastes a very large amount of text, there's no
> problem with your approach. and i think think you'll hit a text length
> limit
> before you hit a performance issue with split().join().
>


kglad
Community Expert
Community Expert
January 29, 2009
unless someone copies and pastes a very large amount of text, there's no problem with your approach. and i think think you'll hit a text length limit before you hit a performance issue with split().join().