Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: GXT Form Validation

  1. #11
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    264
    Vote Rating
    0
      0  

    Default

    thanks Col!

    I'm wondering with this approach;

    PHP Code:
        RegExValidator myEmailValidator = new RegExValidator("^(\\w+)([-+.][\\w]+)*@(\\w[-\\w]*\\.){1,5}([A-Za-z]){2,4}$""Email");
        
    email.getValidators().add(myEmailValidator); 

    Will I be able to use the validator multiple times? Or do I need a separate validator for an additional email CC field?

    PHP Code:
    emailCc.getValidators().add(myEmailValidator); 

  2. #12
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Vote Rating
    93
      0  

    Default

    Why might you need more than one? Do you mean more than one instance? Assuming so, provided you aren't subclassing the validator and adding some state other than what is already there, you shouldn't need one.

    The existing state just covers bits like 'what is the regex', and 'what error message do we use'. If you customize one, and use the same validator in multiple cases, naturally they will all have the same values, whether or not this is what you intended.

  3. #13
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    264
    Vote Rating
    0
      0  

    Default

    Hi Colin,

    Yes more than one instance of the validator,

    I think that I was not sure at whether the re-use of the validator, would mean that if one field was validated then the others would also validate.

    Thanks for clearing this up.

    Neil

  4. #14
    Sencha User
    Join Date
    Apr 2013
    Posts
    32
    Vote Rating
    0
      0  

    Default

    How can i make server side validation. For exepale if the email adress alredy exist ?

  5. #15
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    264
    Vote Rating
    0
      0  

    Default

    Hi, I don't know the best solution is in GXT for that.

    my guess is its based upon GWT serverside validation.

    http://www.gwtproject.org/doc/latest...alidation.html

    One idea I have as a simple solution would be to make the email address the key for you model that way you would get an exception thrown trying to add a record with the same key. However I sure there's a better way.

    Hope this helps until someone else can provide a better response.

Page 2 of 2 FirstFirst 12

Posting Permissions

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