How to add default text that clears on focus with jQuery to a search form text field in Drupal I would like to have a default text in an Exposed Views Search form that says something like 'type in a keyword to search' which will disappear if the user clicks on the text field and reappear if the user removes the cursor and didn't type anything. I would like the title of the field which is added through Views to become the text in the text field box. Should I use pure jQuery to add the text to the box? Or should I use hook_form_FORM_ID_alter() to add the jQuery and change the location of the title?
You can do this by implementing hook_form_alter() in a custom module.

function custom_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if ($form['#id'] == 'search-block-form') {  
        $search_text = 'Your search text here';
        $form['search_block_form']['#default_value'] = $search_text;
        $form['search_block_form']['#attributes'] = array(
        'onfocus' =&gt; "if (this.value == '$search_text') {this.value = '';}",
        'onblur' =&gt; "if (this.value == '') {this.value = '$search_text';}");
    }
}