Move the validate function to the submit button