bal bal Posted March 25, 2009 Share Posted March 25, 2009 hi here is my code for name field which is a text box. it is working if I put any digit or if the field is empty but when I put the symbols like '%$%^&*!' it still takes the value not showing any error. if ((is_numeric($name))||(empty($name))) { echo 'please enter your name<br>'; return; } can anyone please help me... thanks Link to comment https://forums.phpfreaks.com/topic/151096-validate-name/ Share on other sites More sharing options...
lonewolf217 Posted March 25, 2009 Share Posted March 25, 2009 quick google search turned up this quick regex you can use <?php if (ereg('[^A-Za-z0-9]', $text)) { echo "This contains characters other than letters and numbers"; } else { echo "This contains only letters and numbers"; } Link to comment https://forums.phpfreaks.com/topic/151096-validate-name/#findComment-793762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.