Jump to content

Check if text user has input contains only letters.


ZhuXian

Recommended Posts

There are numerous ways to do that, but the most popular one is with regular expressions.You can find more information about their syntax at the manual or at other sites.For doing the check you want, one way is to use the following:

if (preg_match('/[:^alpha:]/', $input)) {    echo 'Error: The input can only contain letters. No spaces, no digits, no punctuation - nothing other than letters.';} else {    echo 'OK. The input contains only letters.';}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...