3 Replies Latest reply on Aug 13, 2013 2:58 PM by Endoplasmic

    Coding - returning the number of characters in a text box.

    Jn7221

      I am in the process of creating a cell phone simulation/animation in Edge Animate CC for use in a Captivate course. Basically, when a user clicks on number buttons on the virtual keypad, it displays the numbers in a text box , just like an actual cell phone would display the phone number on the screen as a caller is dialing. So, the user would click seven buttons and a seven-digit phone number appears on the virtual phone screen.  This part of my animation works great and all seven digits appear, but I would like to modify the code so that a hyphen appears after the third button clicked. This way, the output better resembles an actual phone number instead of just a string of seven digits.

       

      Here is an example of the code I currently have assigned to the #2 button on the virtual keypad:

       

      var text = sym.$("PhoneNum").html();

       

       

      text = text + 2;

       

      sym.$("PhoneNum").html(text);

       

       

      PhoneNum is the name of my text box on the stage where the digits appear as each keypad button is clicked.

       

      In order to incorporate the hyphen after the third button clicked, I need to somehow return the current number of characters in the PhoneNum text box, then create an if/else scenario that applies the hyphen after the third button clicked.

       

      Does anyone know how I can use either JavaScript or jQuery to return the number of characters currently in the PhoneNum text box?