Hey I am looking for a string validator for PHP that will work with this code:
if(!isValidName($name))
{
    $errors[] = lang("MAIL_NAME_ERROR");
}   
That is the code that I have set up now I have tried this 2 codes and they do not return the value outputted here is the codes I tried:
//Checks if an name is valid
function isValidName($name)
{
   if (filter_var($name, MAIL_NAME_ERROR)) {
      return true;
   }
   else {
      return false;
   }
}
That is one that I tried it inputs the error message but does not return the value or reset the value another one that I tried that does not work is this :
function isValidName($name)
{
   if (strcspn($name, '0123456789') != strlen($name))
      return FALSE;
   $name = str_replace(" ", "", $name);
   $result = explode("_", $name);
   if(count($result) == 2)
      return TRUE;
   else
      return FALSE;
}
Basically what I am trying to do is when I don't input my name on my email form I am suppose to get an error message like so :
Please enter your full name
And when I do the message is suppose to go away. Well I get the message alright when the fields are empty but when there are any other values missing I get all the messages back like this :
Please enter your full name
Please enter your telephone number
Please enter your password
Failed security question
Does anybody know a string validator that will work with my string or set up another string?
 
     
     
    