Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

field.hasText crashes app in iPhone

Hi guys,

coming up against a strange error, I've search this QA but this error was different and on Android.

I have a text field which I need to check has something in, simple I know! But doing the simple check of:

tf1.addEventListener('return', function()
    if(tf1.hasText()) {
        alertMessage = tf1.value;
    } else {
        alertMessage = 'Nope';

causes the iPhone simulator to kick the app. No errors in the debug console, I've put an alert just before and just after to see flow and the first alert fires but the hasText check throws it.

Any ideas what I am doing wrong? The end result is me checking the input to see if it's a number… So simple but frustrating.


— asked June 25th 2010 by James Becker
  • crashes
  • field
  • hastext
  • input
  • iphone
1 Comment
  • It's crashing my app, too. Lame.

    — commented June 29th 2010 by Clifton Labrum

3 Answers

  • …Just as easy to just check the value I guess?

    if(tf1.value != '') {

    Interested why hasText blows chunks though!

    — answered June 25th 2010 by James Becker
    1 Comment
    • This same question was asked in another thread 6 months ago… Why has it not been addressed yet?

      — commented August 24th 2010 by Jesse Domack
  • I am running into this issue too. I used your work around which works fine, but yes that is weird why hasText() ain't working.

    — answered October 8th 2010 by Ronnie Swietek
  • Just spent some time wondering why my app keeps crashing…thankfully this Q&A answered it. hasText still crashes the app in the simulator as of 1.2.2

    — answered December 17th 2010 by Chris du Toit
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.