In a module I was developing recently, I needed to add a javascript confirm popup before allowing the user to submit the form. Here is an excerpt from my code to show you how to add the jQuery
<?php
function MYMODULE_main() {
$page_contents = "";
// ...code...
$page_contents .= drupal_get_form('MYMODULE_form');
// ...code...
return $page_contents;
}
function MYMODULE_form() {
$form = array();
// ...code...
$js = "
$(document).ready(function(){
$('#" . str_replace('_','-',__FUNCTION__) . "').submit(function(){
if (confirm('Are you sure?')) {
return true;
} else {
return false;
}
);
});
";
drupal_add_js($js, 'inline');
// ...code...
return $form;
}
?>









