suttercain Posted August 28, 2007 Share Posted August 28, 2007 Hi guys, I am allowing the user to create a URL and I would like to prevent the form from processing if they type something like 'jake 12' How would I check for a space? Thanks. SC Link to comment https://forums.phpfreaks.com/topic/66968-prevent-a-single-space-in-a-form-field/ Share on other sites More sharing options...
Fadion Posted August 28, 2007 Share Posted August 28, 2007 if(strstr($string, ' ')){ $string = str_replace(' ', '', $string); } Link to comment https://forums.phpfreaks.com/topic/66968-prevent-a-single-space-in-a-form-field/#findComment-335843 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 if (!preg_match('/\s/', $string)) { # No Space } else { # Has a Space } Link to comment https://forums.phpfreaks.com/topic/66968-prevent-a-single-space-in-a-form-field/#findComment-335845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.