speedy33417 Posted November 12, 2006 Share Posted November 12, 2006 I have a little problem validating a user entryHere's the code:[code]if (preg_match('![a-z0-9\-_]+!',$albumName)) { //passed $message = "passed"; } else { // failed $message = "did not pass"; } [/code]The code should only accept a-z0-9 dash and underscore.For some reason it only checks the first letter and user entry such as a@#$ slip through. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/27019-validate-help/ Share on other sites More sharing options...
448191 Posted November 12, 2006 Share Posted November 12, 2006 Include the beginning and end of the line or string:[code]/^[A-z0-9\-_]+$/[/code] Link to comment https://forums.phpfreaks.com/topic/27019-validate-help/#findComment-123571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.