4 Replies Latest reply on Sep 13, 2007 7:52 AM by Barb

    How to identify if form control is NULL

    Barb Level 1
      I have a form that has certain fields that are not required. Once the user completes the form and clicks submit, I am writing the values of the form fields back to a .db file. The problem I'm running into is that if a form textinput field is left blank, my insert statement fails because it says "Main Thread (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.) " for the value of the blank form field (in example below, "phone" is not required).

      var sql:String =
      "INSERT INTO inquiry " +
      "(firstName," +
      "lastName," +
      "email" +
      "phone, " +
      "bio " +
      ") " +
      "VALUES " +
      "('"+firstnameValid.text+"', '"
      +lastnameValid.text+"', '"
      +emailValid.text+"', '"
      +phone.text+"', '"

      I tried:

      var phone_input:String;
      if (phone.data == "")
      {phone_input = "";}
      {phone_input = phone.text;}

      But get the same error on the if(phone.data =="") line.

      Any suggestions? Thanks!