Run javascript code on Form Submit I want to run JavaScript code upon a form being submitted preceding other default tasks that are carried out on form submission.

May anyone suggest some approaches?
Depending on the type of code that you need to run, and from the Drupal version, AHAH and AJAX could be the answer.

On Drupal API, there is example code for AHAH (Drupal 6), and AJAX (Drupal 7 and higher).