How do you get Length of Text in a Mojo TextField?
Posted
by figus
on Stack Overflow
See other posts from Stack Overflow
or by figus
Published on 2009-08-17T05:33:15Z
Indexed on
2010/05/11
23:04 UTC
Read the original article
Hit count: 370
How do you get the length of the text inside a Mojo TextField?
I'm trying to set a multiLine TextField with a limit of 150 chars, I tried doing it with a counter, but ran into a issue of not being able to decrement the counter when the text was erased, or adding the right number when pasting text, so my new approach was to get the length of the text each time you press a letter.
I've already tried this: (gets called in the charsAllow
attribute of the textField
)
if (this.controller.get("mensaje").mojo.getValue().length <= 150) {
return true;
}
this.controller.get("mensaje").mojo.blur();
return false;
but it doesn't work.... I debugged and the function exits just after the line in bold... it doesn't even returns true
or false
.
I also tried assigning the length value to a variable or assigning the text to a variable and then get the length, but nothing.
It's the same issue. It returns just after the getValue()
.
Also, maybe because of this issue, the text scrolls instead of wrapping, but when the textField
loses focus it wraps the text.
© Stack Overflow or respective owner