Re: Check For Space
| From: | Chris Hayes | Date: | Wed, 02 Apr 2003 16:13:00 +0000 |
| Subject: | Re: Check For Space | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141999@lists.php.net to get a copy of this message | ||
At 17:16 2-4-03, you wrote:
Hi, How can i make sure a value sent from a form has no spaces in it?Before sending: javascript that prevents this on sending or even while typing. Check the javascript form faqs on www.irt.org for this. After sending: Detect spaces with if (!(strpos(' ', $string)===false) {ECHO "bloody idiot, i told you not to do that. Stupid User!";} In PHP you can remove spaces at start and end of the entry with trim(...). Remove all spaces in a string with $string=str_replace(...) (replace " " with ""). (see manual www.php.net/manual for proper use of these functions.)