manipulate form variables before render()
The Form API has #pre_render per element. You can use hook_form_alter to add your pre-render function to the list of functions that need to be called to show the value.


  #pre_render
  
  Used by: All elements and forms.
  
  Description: Function(s) to call before rendering in drupal_render()
  has occured. The function(s) provided in #pre_render receive the
  element as an argument and must return the altered element.
  
  Values: An array of function names to call.
  
  Note: If you are altering an existing form via hook_form_alter() or a
  similar means, be careful with this property! As demonstrated here,
  you will probably want to add to the existing array rather than
  writing over it.


I recommend being careful of when your module runs when trying to interact with Forms, Ajax, etc (your modules' weight). If needed I also recommend seeing hook_module_implements_alter if you want to adjust when your hook is called, without affecting your modules' weight.