Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-5810

Android: maxLength propery on TextField and TextArea

    Details

      Description

      TextField and TextArea needs a property to control the max length of the input text.

      Though this can be done using an eventlistener and a length check. It would be very useful if this was built-in.

      var win = Ti.UI.createWindow();
       
      var txt = Ti.UI.createTextField({
          top: 150,
      	height: 100,
          backgroundColor: "white"
      });
       
      /* var txt = Ti.UI.createTextArea({
          top: 150,
          height: 100,
          backgroundColor: "white" */
       
      var button = Ti.UI.createButton( {
          title: "set max length to 10"
      });
       
      button.addEventListener('click', function(e) {
         txt.maxLength = 10;
      });
      Ti.API.info("maxLength: " + txt.maxLength);
      win.add(txt);
      win.add(button);
      win.open();
      

      1. Run code
      2. Check log, make sure maxLength is -1
      3. Click on button
      4. Start typing, the content should not exceed 10 characters.
      5. Re-run code, this time enter 20+ characters before click on button
      6. Click on button, text now should truncate to 10 characters
      7. Repeat 1-6 on textArea.

        Attachments

          Activity

            People

            • Assignee:
              hpham Hieu Pham
              Reporter:
              mofle Sindre Sorhus
            • Watchers:
              3 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code