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? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.