How to alter user's input? I have a form to get some user input in Drupal. I want to add some prefix to the user input.

For example, the user enters "Laptop"; I want to save it in the database as resource_Laptop. I want to add the prefix before the validation is done, to avoid it fails.

How do I do this? Will hook_form_alter() help me here?

I have used this method, but not satisfied with this hack.

function mymodule_form_alter(){
  drupal_add_js("
    (function ($) {
      $(document).ready(function() {                    
        $('.field-suffix').hide();  
        $('#edit-submit').click(function(){
        var s = $('#edit-machine-name').val();

        if (s.indexOf('_resources') == −1) {
          $('#edit-machine-name').val($('#edit-machine-name').val() + '_resources');
        }
      });   
    })(jQuery);", 'inline');
}
Use the hook_form_FORM_ID_alter and add a custom submit handler.

function example_form_form_id_alter(&amp;$form, &amp;$form_state,$form_id){
  $form['#submit'][] = 'example_form_id_submit',
}

function example_form_id_submit(&amp;$form,&amp;$form_state){
  $form_state['values']['resource_name'] = 'resource_' . $form_state['values']['resource_name'];
}