Finally I've defined a new regex validator. It looks like this:

class MyValidator extends Zend_Validate_Abstract {
    
    const INVALID_CHARACTERS = 'invalidCharacters';
    
    protected $pattern = "/[^a-zA-Z 0-9áÁéÉíÍóÓúÚöÖüÜñÑçÇ]/";
    
    protected $_messageTemplates = array(
        'invalidCharacters' => 'This field contains illegal characters'
    );
    
    function isValid($value) {
        
        if (preg_match($this->pattern, $value)) {
            $this->_error(self::INVALID_CHARACTERS);
            return false;
        }
        return true;
    }
}

I'm sure that ugly regular expression can be reduced. I'll try =^D




Agenjo wrote:
> 
>  Hi there!
> 
>  Well, I'm using Zend Framework to create and validate some forms. I need
> to validate some people and institution names which contain stressed
> characters as á, é, ó and so on (I work with Spanish names), but it says
> they aren't valid characters...
> 
>  Does anyone know how can I validate names including those characters?
> 
> 
>  Thanks!!
> 

-- 
View this message in context: 
http://www.nabble.com/%C2%BFZend_Validate_Alnum-validation-of-stressed-characters-%28%C3%B3%2C-%C3%A9%2C-%C3%BC...%29--tp16467429p16537495.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to