-
1 Aug 2012 11:20 PM #11
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);
-
9 Dec 2012 11:00 PM #12
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.
-
10 Dec 2012 12:49 AM #13
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


Reply With Quote