How to give class name to the text field in drupal
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.