Switch to preg_match:
if(!preg_match("/[a-zA-ZáéíóúñÑ ]+$/",$valor))
It's faster, more flexible, and doesn't have this problem.
Or, given the form of your regexp, consider using
if(strspn($valor," abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZáéíóñÑ ") != strlen($valor))