Set maxLength at client side

  1. #1

    Set maxLength at client side

    Hi,

    If I set MaxLength property to a TextField control it limits the amount of characters to write in the input field.

    I need to change maxLength value of TextFields and NumberFields controls at client side. But when I set txtField.maxLength = 15 it doesn't have the same behaviour and it is possible to write more than 15 characters. A tip with a warning message is show but I need to limit the numbers of characters too.

    How can this be done?

    Thanks in advance,

    Dominik.
  2. #2
    Ok,

    It can be done in any of these ways:

     txtField.getEl().dom.maxLength = 15;
     txtField.getEl().set({ maxlength: 15});
    Regards,

    Dominik.
  3. #3
    New .setMaxLength property has been added and the change has been committed to SVN (Revision #3465).

    [NEW] Added new .setMaxLength() function on Ext.form.TextField.js. Allows for dynamically setting the .maxLength property after component render.
    The .setMaxLength() function will not fire the .validate() function to validate the Field. If you want to change the maxLength value and validate the Field, please call .validate() after calling .setMaxLength(val).

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 3
    Last Post: Dec 26, 2011, 1:32 PM
  2. Replies: 1
    Last Post: Dec 01, 2010, 5:14 PM
  3. Replies: 4
    Last Post: Mar 19, 2010, 11:35 AM
  4. Replies: 0
    Last Post: Sep 17, 2009, 8:04 AM
  5. Replies: 6
    Last Post: Sep 01, 2009, 1:06 PM

Posting Permissions