SolidJS2mo ago

Form validation help

Hi, I am trying to use the form validation example (https://www.solidjs.com/examples/forms) from Solidjs site but getting an error "Property 'use:validate' does not exist on type 'InputHTMLAttributes...." in my tsx file. How do I get around this problem? I have a simple 5 field form that needs some validation but the provided example seems complicated, to me at least. Appreciate any help/guidance. Thanks
Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.
1 Reply
peerreynders2mo ago
It has been my observation that while use:* directives can be convenient in JSX, in the long term they seem to create a disproportionate burden on maintainers when it comes to supporting TSX. So if TypeScript is a must then perhaps let go of use:* directives. Here is the same code in TS and without use:*: https://stackblitz.com/edit/stackblitz-starters-nlchtj?file=src%2Fapp.tsx You're trading use:* for refs and it's still using native capabilities while leveraging Solid's unique strengths. This wouldn't be the first time that TypeScript is responsible for code bloat.
MDN Web Docs
Client-side form validation - Learn web development | MDN
Client-side form validation sometimes requires JavaScript if you want to customize styling and error messages, but it always requires you to think carefully about the user. Always remember to help your users correct the data they provide. To that end, be sure to: