How to give class name to the text field in drupal I am new to drupal and I have a problem in drupal text-box.

Question : how to give a class for text box?

my html : 

&lt;input type="text" name="uname" class="uclass" id="uid"&gt;


i want the same in drupal

My code is :

function my_module_my_form($form_state) {

// This is the first form element. It's a textfield with a label, "Name"

$form['name'] = array(

'#type'  =&gt; 'textfield',
                    '#title' =&gt; t('Enter Your Name'),
                    '#value' =&gt; t('Enter user name'),
                    '#name'  =&gt; 'uname',
                    '#id'    =&gt; 'uid',
                    '#class' =&gt; 'uclass',
                    '#maxlength' =&gt; 5
                   );
return $form;

}


Note: through inspect element , i find the class name is "form-text", but actually my class name is uclass, It is not taking, can one help me.
Additional HTML attributes, such as 'class', can be added using the '#attributes' property.

function my_module_form_FORM_ID_alter(&amp;$form, &amp;$form_state, $form_id) {
   $form['name'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; t('Enter Your Name'),
      '#weight' =&gt; -10,
      '#attributes' =&gt; array('class' =&gt; array('uclass')),
    );
 }


Please note that when you alter existing form elements (e.g. via hook_form_alter()), you probably want to add (attributes) to the existing array rather than writing over it.

Checkout Form API of Drupal 7 to get more detail.