1 Reply Latest reply on Sep 28, 2012 5:16 AM by Ned Murphy

    Detecting Text Input


      How do i detect if there is some text entry in the input text field.


      ---------------------------------------------------------------------- -------------

      this.tf1_txt.text = "";

      this.tf1_txt.onSetFocus = function() {

      tf1_txt.text=(tf1_txt.text == "")?  "" : tf1_txt.text ;






      }else {





      this.submit_btn.onRelease = function  () {





      ---------------------------------------------------------------------- -----------------


      If I am using If . . else if. How would the above code mentioned in red color change ?

        • 1. Re: Detecting Text Input
          Ned Murphy Adobe Community Professional & MVP

          If that is a multiline textfield then you will find it comes with some extra baggage in the form of a carriage return.  So even before any text is entered into it there is that living there.  It can be deleted if you were to use the delete key while the textfield looked empty.  So since the textfield could have 0 or 1 characters and be empty, you might want to change your test to be <2 insteasd == ""


          You should avoid unnecessary use of "this"   If the code is in the same timeline as the object it is targeting, there is no need for it and it can cause problems.  If your textfield happens to be a single line textfield, using this could cause a problem.


          You should learn to use the trace() function to troubleshoot your coding.  It allows you to see what values are being processed and enables you to question why some are not what you expect them to be.

          1 person found this helpful