I would like to check if at least a digit was inserted after the first name in this input.
So, if the user input ‘joe’ it will not validate, but ‘joe d’ or ‘joe doe’ it will pass.
How can this be done?
$nome = $this->coalesce($form['nome']);
if (strlen($nome) > 0)
$this->setValue('nome', strtoupper($nome));
else
$this->addError('nome', 'Invalid name!');
You can use a regex to do this:
You can change the regex to
'/[A-Za-z]+ [A-Za-z]+/', since\wwill match more than just alphabetic characters (it includes numbers and underscores).