catch enter functionality for form, make form validation into separate function for reuse.

Signed-off-by: Galen Vinter <galen.vinter@gmail.com>