Resize the registration email and name textfield in drupal 6

Joined: 01/19/2009
User offline. Last seen 1 year 46 weeks ago.

Hi all,i wonder how to resize the default usename and email textfield size in drupal 6 registration form?Thanks a lot...
This is what i found out

<input type="text" class="form-text required" value="" size="60" id="edit-name-1" name="name" maxlength="60"/>

<input type="text" class="form-text required" value="" size="60" id="edit-mail" name="mail" maxlength="64"/>

Joined: 12/16/2007
User offline. Last seen 27 weeks 4 days ago.
CSS

You do this in CSS with modern browsers IE 6, 7 and 8 all support this. The size="60" attribute in the code refers to the character length of the text box.

Here's the selector you would use:

#user-login-form input.form-text {
  height: (your value);
}

Blessings,
Tony

Joined: 10/18/2008
User offline. Last seen 1 year 27 weeks ago.
To change the "size"

To change the "size" attribute would require a hook_form_alter or some javascript and you do want to give the user the ability to enter up to 60 characters. However, to make it appear a different size, simply use the css width:

/* To copy Anthony's code */
#user-login-form input.form-text {
  width: 120px;
}

If you want to also edit the user registration page AND the user profil page you'll need to add other selectors:

/* To copy Anthony's code */
#user-register input.form-text,
#user-profile-form input.form-text,
#user-login-form input.form-text {
  width: 120px;
}

/ * Begin Signature */
It's a strange thing about determined seekers-after-wisdom that, no matter where they happen to be, they'll always seek that wisdom which is a long way off. Wisdom is one of the few things that looks bigger the further away it is.

G&G Moderator
G&G Podcast Host
micah's picture
Joined: 06/21/2007
User offline. Last seen 2 weeks 1 day ago.
Resizing fields using a custom module

You could also resize the field using a custom module.

For example, if you created mysite.module, you could use something like this to reduce the field size to 30 characters:

function mysite_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_profile_form':
      $form['account']['name']['#size'] = 30;
      $form['account']['mail']['#size'] = 30;
      break;
  }
}

I'd be cautious about making the fields larger than the maxlength already specified, since that type of change could make your data larger than the field sizes in the user table, but you could use this to make them smaller. If you only want to do this for appearance sake, I'd use the CSS examples shown above.

Micah