1. #1
    Ext User
    Join Date
    May 2010
    Posts
    19
    Vote Rating
    0
    hbonpard is on a distinguished road

      0  

    Default AVOID CHARACTERS IN A TEXTFIELD

    AVOID CHARACTERS IN A TEXTFIELD


    How can i avoid that a user types some character(for example '<') in a textfield?

  2. #2
    Sencha User
    Join Date
    Jun 2009
    Location
    Flanders
    Posts
    45
    Vote Rating
    0
    daddieke is on a distinguished road

      0  

    Default Regular expressions

    Regular expressions


    You can use a regular expression on a TextField using setRegex.

  3. #3
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    870
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    Well. Many ways:

    1 - You can listen for entered keys, and if < is entered, you remove it, or display some message...
    2 - you can add a validator via setValidator (but that will only be checked when leaving the field, not when typing)
    3 - As suggested, you can set a regex expression via setRegex(but that will also be only checked when leaving the field, not when typing)

  4. #4
    Ext User
    Join Date
    May 2010
    Posts
    19
    Vote Rating
    0
    hbonpard is on a distinguished road

      0  

    Default


    Quote Originally Posted by micgala View Post
    Well. Many ways:

    1 - You can listen for entered keys, and if < is entered, you remove it, or display some message...
    How can i do it?

  5. #5
    Sencha User
    Join Date
    Jun 2009
    Location
    Flanders
    Posts
    45
    Vote Rating
    0
    daddieke is on a distinguished road

      0  

    Default Handle event

    Handle event


    Add a listener to the field using addListener(...) and implement the handleEvent method to do what you want.
    Specify what event you want to listen for, I suppose you need something like Events.KeyPress or one of the other Key... - events.

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    1
    Vote Rating
    0
    jameskatter is on a distinguished road

      0  

    Default Texttield.maskRe

    Texttield.maskRe


    I fixed it by using Textfield.maskRe = /your regular expression/
    This will avoid user to type anything which does not comprehend your regex.
    remember on put your regEx into forward slashes!!

    hope this help you guys.