Drupal form FAQ: How do I create an HTML password field in a Drupal form (using Drupal 6 or Drupal 7)?
Assuming that you're comfortable with creating a Drupal form in general, you can create a Drupal form password field like this:
$form['password'] = array( '#type' => 'password', '#title' => t('Password'), );
Here's what this simple, default Drupal form password field looks like:
You can control the Drupal password field by adjusting more password field properties, as shown next.
More Drupal password field properties
For more control over your password field, just add more Drupal form field definitions to your password field definition, like this:
$form['password'] = array( '#type' => 'password', '#title' => t('Password'), '#description' => t('Please enter your password'), '#size' => 32, '#maxlength' => 32, '#required' => TRUE, );
Hopefully most of these Drupal password field options are self-explanatory, but if not, just leave a note in the Comments section below.
For more information on Drupal form password field properties, see this Drupal Form API reference page.
Drupal form password field examples - Summary
I hope this Drupal form password field example has been helpful. If you have any questions just leave a note in the Comments section below and I'll be glad to provide more information.