A case study of using web component
published on 2022/05/04
- I used HTML validation attributes to enforce required fields (and could have done more with pattern based validation)
- I used the FormData API to read values out of the form rather than track their values in state (which I didn’t need to, because the validation was done by the browser).
- If I wanted to, I could even customise the error messages using the Constraint Validation API - an API I didn't even know existed until a few days ago!
The Web Platform is progressing really quickly. It's a good practice to stop and study what's already available in the platform and adopt them.