I want to run a JavaScript code upon a form being submitted preceding other default tasks that are carried out on form submit.
Can anyone suggest some approaches?
I am not sure if drupal has any special way to automate this or make it easier but in just normal HTML javascript you would do it like:
<input type="submit" onClick="doStuff();" value="Submit"> //Note: you can use return(doStuff()); and if doStuff returns false then the form will not submit (great for checking if all fields are filled out correctly).