Php - Validate Name

PHP - Validate Name
The code below shows a simple way to check if the name field only contains letters, dashes, apostrophes and whitespaces.

Only letters and white space allowed

preg_match("/^[a-zA-Z-' ]*$/","Your Name");
$name ='MD SAZZAD';
if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
  $nameErr = "Only letters and white space allowed";
}

Write a Associte Comment
Markdown Editor