views:

282

answers:

2

hi!

the default login form in drupal doesn't have any javascript to check whether the fields(Username and password) are empty or not before submitting the form. so, i want to add it onsubmit to the user login form..how can i do that?

A: 

please read how to theme login block: http://drupal.org/node/19855

And attach to submit button one of these javascript functions: http://www.tizag.com/javascriptT/javascriptform.php

Nikit
+1  A: 

The best way would be to just create a module that adds a .js file (via drupal_add_js()) that does something like this (note: the classes here are just a guess, didn't check the actual class names):

$('.login-form .form-submit').click(function() {
    // your error checking here
});
Mike Crittenden
True, but don't forget to wrap that in the well known jQuery: $(document).ready(function(){ ... });
marcvangend
Actually, $(document).ready isn't recommended for modules. Instead, use a behavior: http://api.drupal.org/api/drupal/developer--topics--javascript_startup_guide.html/6#drupal-js-api
Mike Crittenden

related questions