Show password button
Password Toggle is already doing something of this sort. Code is simple and straight

Its basically a JS to be added at the right time.

function password_toggle_add_js_and_css() {
  $path = drupal_get_path('module', 'password_toggle');
  drupal_add_js($path . '/password_toggle.js');
  drupal_add_css($path . '/password_toggle.css');
}


You can borrow the module's js code for your module.