add validation function to form