4

I'm developing a module and in the settings page I've inserted a text field to allow users to insert a key.

I thought to change this into a password field but I want to also create a Show password button or a checkbox. How could I implement this functionality?

2 Answers 2

9

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.

4

That's the kind of functionality you'd want to implement with jquery.

If you google up "jquery show password" you'll get over a million results.

First on the list you get this fiddle http://jsfiddle.net/herdiansc/dnznh/8/ which does the trick with a checkbox.

Do you see how you can adapt that jquery script to your module ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.