Validating and Modifying Form Data Simultaneously I have a custom phone number field that I would like to be able to validate and modify simultaneously.

I want to make sure the field has a total of 10 digits regardless of the formatting.

The following values should all be 'valid'

555.555.5555
(555) 555-5555
(555) 555.5555
555-555-5555
5555555555


Can I have a validate function return a new value upon success? In essence, as long as there are exactly 10 digits present the validate function should return '5555555555' for every value above.
The $form_state variable is passed to your validation function by reference. This means you can indeed alter the value while validating it.

function mymodule_myform_validate($form, &amp;$form_state) {
  if (...) {
    // Value is valid
    $form_state['values']['my_form_element'] = NEW VALUE;
  }
  else {
    // Set form error.
  }
}