Form field validations

Form field validations

·

1 min read

Ques:

Instead of using the state data and validating the inputs and providing the validation messages, can we use the built in HTML features? E.g. for a textbox we mention "required" in the input tag? This would reduce the code a bit but wanted to check in react world is it recommended.

Answer:

The default HTML validation is fine but it does not give a good user experience to the user. With custom validation, we have a lot more control to handle different variants of validation (both simple and complex ones) like async validations, our own user defined validations and much more. With HTML validation, we are giving this control to HTML.