You could do it in many ways, such as if you wanted form validation, you could have:
<script language="javascript">
<!--
function check(){
if(document.form_name.object_name.value.length == 0){
alert('something');
return false;
other JS commands
}
}
//-->
</script>
<input type="submit" name="submit" onClick="return check();">
You could also have it in the form tag, <form name="something" method="post" action="URL" onSubmit="reurn check();">
}