checking to make sure form is valid before posting