1. #11
    Sencha Premium Member Neilcoder's Avatar
    Join Date
    Apr 2011
    Location
    Ireland
    Posts
    209
    Vote Rating
    0
    Neilcoder is on a distinguished road

      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
    Posts
    2,020
    Vote Rating
    56
    Colin Alworth is a jewel in the rough Colin Alworth is a jewel in the rough Colin Alworth is a jewel in the rough Colin Alworth is a jewel in the rough

      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
    209
    Vote Rating
    0
    Neilcoder is on a distinguished road

      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