Results 1 to 6 of 6

Thread: validate value for textbox validate values are comma separated

  1. #1
    Ext User
    Join Date
    Jan 2008
    Posts
    140

    Default validate value for textbox validate values are comma separated

    Hi,

    I am having one text box in my grid..it can have values like 1 or 1,2 or 1,2,3 ie multiple values are comma separated also 1,2,3 values are not fixed they are dynamic..i display tool tip against each cell as user should add values as 1 or 1,2 or 1,2,3 ie multiple values separated by comma.
    But now i want extjs itself should validate weather values entered by user are proper or not onclick/blur of that text box..can i use validateValue function if yes then how? can you tell me 1 example?i can't use extjs's plugin's multiselect box..

    Thnx & Regds,
    - Amey

  2. #2
    Ext User
    Join Date
    Jan 2008
    Posts
    140

    Default


  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    A validator function should work, e.g.
    Code:
    validator: function(v){
    	if(!/^\d+(,\d+)*$/.test(v)){
    		return 'This field needs to contain a comma-separated list of values';
    	}
    }
    (you could also create a vtype for this)

  4. #4
    Ext User
    Join Date
    Jan 2008
    Posts
    140

    Default

    thnx condor but what does test signify in that??how can i pass list of values in that function it should be simplestore?

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    test is the function called on the regular expression ahead of it. If you don't understand this, I suggest googling - there are many resources to teach you regular expressions.

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    The validator function should be used in the textfield config (see API docs).

    You can find info about javascript regexp here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •