Validate and submit

validate() checks the content of the form. If everything is correct, submit() submits the form.