how to set Drupal Auto complete OFF I am new to drupal i want to set auto complete off in my following code

$form['plantuser']['username'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Username'),
    '#description' =&gt; t(''),
    '#required' =&gt; true,
    '#maxlength' =&gt; 50,
     '#weight' =&gt;1,
  );
That code doesn't enable Drupal's autocomplete (it would need the #autocomplete_path property to do so), so I guess you mean the browser autocomplete?

The standard way to do that is to set the autocomplete attribute on the element which you can do like this:

  $form['plantuser']['username'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Username'),
    '#description' =&gt; t(''),
    '#required' =&gt; true,
    '#maxlength' =&gt; 50,
    '#weight' =&gt;1,
    '#attributes' =&gt; array('autocomplete' =&gt; 'off'),
  );


Bear in mind autocomplete is only valid using the HTML5 doctype; if you're using another doctype you'll need to implement a JS solution to set the attribute instead, e.g.

(function($) {
  $(function() {
    $('#input-id').attr('autocomplete', 'off');
  });
})(jQuery);