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 Quote 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); } Quote 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 } Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.