Kryptix Posted December 30, 2009 Share Posted December 30, 2009 I need to validate form submission to check every character they have entered is a-z, A-Z, 0-9 and either a underscore or a space. How would I do this? Add every character to an array and then check or is there a better way? Link to comment https://forums.phpfreaks.com/topic/186672-validating-characters/ Share on other sites More sharing options...
cags Posted December 30, 2009 Share Posted December 30, 2009 This topic is marked as 'Solved' so I assume the OP worked it out but in case anybody else reads this, there are lots of ways, here's one.. if(preg_match('#[^a-z0-9_ ]+#i', $input)) { // invalid characters } else { // no invalid characters } Link to comment https://forums.phpfreaks.com/topic/186672-validating-characters/#findComment-985929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.