Added display errors on submit button click.
Moved checks for display errors to a function.