English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

So far i got if ($_POST["Username"] == "" or (!ereg("^[a-z0-9]", $_POST["Username"])))

I just cant seem to find any code that will stop spaces being acceptable. I need spaces to not be allowed. Can anyone help?

2006-11-09 09:18:23 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

This will strip any leading/trailing spaces from $content & then remove all spaces from the $content

$content = preg_replace("/ +/", " ", trim($content));
$content = str_replace(" ", "", $content);

2006-11-09 09:41:00 · answer #1 · answered by Farnsworth 3 · 0 0

I assume that you are allowing them on the form page, but not the page that processes the form... as in there is no javascript to disallow entering it on the form.

okay, you're on the right track. The regex you have there will only allow lowercase characters and numbers... and only one character! Try using the [:blank:] regex special character.

2006-11-09 09:25:02 · answer #2 · answered by destillman 2 · 0 0

fedest.com, questions and answers