Or for a more lightweight version of the above:
$var = str_replace(" ", "", $var);
(that's quote - space - quote as the first parameter, and then quote - quote as the second parameter).
str_replace is faster than either ereg_replace or preg_replace for simple replacements like this. But you probably won't notice a difference in speed unless you're processing a large amount of strings (which you're probably not, unless your form is crazy big!)
This might also be a little easier for you to read when you maintain your code in the future.