Re: Beginner question : Removing spaces in forms
| From: | Doug Parker | Date: | Fri, 13 Dec 2002 06:02:11 +0000 |
| Subject: | Re: Beginner question : Removing spaces in forms | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128123@lists.php.net to get a copy of this message | ||
I've solved similar things, i.e. removing commas from a number of text fields, by looping through the input boxes and doing a search/replace - all using Javascript via the onSubmit event. This chunk of code removes commas from input boxes:
<script>
for (var i = 0; i < form.elements.length; i++)
{
var pattern = /,/ig;
var newString = form.elements[i].value.replace(pattern,"");
form.elements[i].value = newString;
}
</script>
In your case, you'd just replace the "," with a " ". I don't know of an easier way, though if one exists I'd would like to know about it.
Andrew Wilson wrote:
Hay guys i was wondering if there was a form parameter of something equivalent for input text boxes that when a user enters a number or series of numbers that it removes the spaces. If there is no alternative how would you go about solving this issue. Your help is appreciated. Thanks. Netway Networks Pty Ltd (T) 8920 8877 (F) 8920 8866