How to control when the form is get submitted?