Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would likely agree, however this example makes heavy use of hyperscript, which is an associated project by the same author, but is distinct from HTMX.


How do you do validation with custom error messages without it? It seems pretty table stakes for forms to me.

Where are the docs that make it easy to avoid hyperscript, if it's usable without hyperscript? This has hyperscript sprinkled in: https://htmx.org/docs/


HTML already has a native validation API for form elements. https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_va... HTMX wraps that with some custom events and enables you to use the same API for non-form elements.

In the example above, if you need custom validation logic, you could handle the HTMX:validation:validate event with any normal JS event handler.

Of course, it's up to you to decide how much effort to put into client-side validation that can be easily bypassed.


Mostly, you validate on the server and send html with error messages back.

If you really need client-side, yes, of course you have to script it. If hyperscript is not to your taste, you use a bit of js.


That was implicit in my question. We aren't talking about writing purely server side web apps here, and it's reasonable to expect something like client side validation, given that this is meant to be an easy way to do full stack web apps. I think it is but not really easier than other major ones.


> We aren't talking about writing purely server side web apps here

Ok, but note that a big part part of the appeal of htmx is that yes, you work mostly server-side. If your use case absolutely needs client side code, htmx might not be the right fit. (But in many cases you don't need as much client-side Code as you might think at first.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: