How can I alter the contents of a form before they are submitted?
You may be interested in form_set_value().  You would use this within the form validation function.  There are examples of its use posted below the API documentation in the comments if you need further clarification.

For help creating a validation function, see the Form API Quickstart Guide (D6) or How to use the Form API (D7).