The "getElementById" is to actually get the form and submit it once someone has clicked the button.
The other question you ask is a tad bit more complicated, javascript-wise you could use the "onsubmit"-function which is called once the form is, that's right, about to be submitted.
Otherwise if you're using PHP and the form has been submitted, you can use a ton of methods to verify someone has submitted something. For instance you can check if a field has been submitted by checking that $_REQUEST['fieldName']; (POST or GET should be used here instead of REQUEST) is set.