Monday, March 19, 2012

D7 alter login form set default username password



function MYMODULE_form_user_login_block_alter(&$form, &$form_state) {
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'MYMODULE') . '/js/login_form.js',
  );
}



login_form.js
==========
(function ($) {
  $(document).ready(function() {
    var name = document.getElementById("edit-name");
    name.value = "demo";

    var pass = document.getElementById("edit-pass");
    pass.value = "password";
  });
})(jQuery)





No comments:

Post a Comment