php - preg_match pattern check that strin contain only letters,whitespace and dot -
An easy way to check the code below shows that the name field only includes letters and white space if If the value of the Name field is not valid, archive an error message:
$ name = test_input ($ _ POST ["name"]); If (! Preg_match ("/ ^ [a-zA-Z] * $ /", $ name)) {$ nameErr = "letters and white space allowed only"; } My question is how can I add dot (.) here?
Exchange this line:
if (! Preg_match (" / ^ [a-zA-Z] * $ / ", $ name)) if (! preg_match (" / ^ [a-zA-z \. * * $ / ", $ Name]) To avoid the character of . , as it has a special meaning in its regular meaning.
Comments
Post a Comment