Prevent Empty Form Values with Conditional Submit Handlers

Share this video with your friends

Send Tweet

We’ll take advantage of the controlled nature of the todo input and the first class nature of javascript functions to dynamically assign the form submission handler. An empty todo will trigger a submission handler that is only concerned with handling an error state, and when the input is valid, the form will use the standard submit handler.

danielpoulson
danielpoulson
~ 8 years ago

My Chrome React devtools do not show "bound" and then the function that is bounded they only show "fn"

Andy Van Slaars
Andy Van Slaars(instructor)
~ 8 years ago

Have you tried pulling down the repository code to see if it works from the source?

andrew kusuma
andrew kusuma
~ 6 years ago

Thank you Andy, const submitHandler make sense for me to create UX validation. How about handle multiple input? and show error message when one or all input is empty or wrong format. Do you any idea for that case?

Thank you

dave
dave
~ 5 years ago

Why isn't form validation handled in the form ?