Conditionally enable/disable #autocomplete from client side js I have a custom search field which searches for a type of content depending on the radio box selected. I have applied autocomplete functionality to the field using hook_form_alter but only want the autocomplete functionality to be available for one of the search types. 

Is it possible to conditionally detach the Drupal.behaviors.autocomplete from the text field using my own js?

Update:
I have managed to disable the autocomplete functionality by unbinding the events, but I do not know how to add/bind it again:

// update search box text when search type is changed
$(SI_SEARCH.radio).change(function() {
  // get search type
  SI_SEARCH.search_type = $(this).val().trim();
  switch(SI_SEARCH.search_type) {
    case 'course' :

      break;
    case 'university' :
      // disable autocomplete
      $('#edit-search').unbind('keydown keyup blur');
      break;
  }
})
Ok I managed to achieve this after digging into misc/autocomplete.js

To disable the autocomplete you can do the following:

$('#edit-search').unbind('keydown keyup blur');
$('#[AUTOCOMPLETE-ELEMENT-ID]-autocomplete-aria-live').remove();
$('#[AUTOCOMPLETE-ELEMENT-ID]-autocomplete').removeClass('autocomplete-processed');


To enable the it again:

Drupal.behaviors.autocomplete.attach(document);


My js ended up as:..

// update search box text when search type is changed
$(SI_SEARCH.radio).change(function() {
  // get search type
  SI_SEARCH.search_type = $(this).val().trim();
  switch(SI_SEARCH.search_type) {
    case 'course' :
      // re-attach autocomplete
      Drupal.behaviors.autocomplete.attach(document);
      break;
    case 'university' :
      // disable autocomplete
      $(SI_SEARCH.search_form).next().removeClass('autocomplete-processed');
      $(SI_SEARCH.search_form).unbind('keydown keyup blur');
      $('#edit-search-autocomplete-aria-live').remove();
      break;
  }
})