Hacker News

Favorites Setup
Comment by AdieuToLogic | original | HTML Can Do That
[−]AdieuToLogic · 2026-08-21 Fri 04:02 UTC · link
> I don't often have to write frontend code, but when I do, there is very little in terms of interactivity you cannot do with HTML these days, worst case a little sprinkle of something like HTMX.

And for some front-end form field validation in the spirit of htmx, ParsleyJS[0] is quite nice. Below is one way to enable the former to support the latter:

  htmx.defineExtension (
      'parsley-validation',
      {
          onEvent : function (name, evt) {
              var allow = true;
  
              if (name === 'htmx:load')
                  $(evt.target).parsley ();
              else if (name === 'htmx:confirm') {
                  var theForm = $(evt.target).parsley ();
  
                  theForm.validationResult = allow = theForm.isValid ();
  
                  if (!allow)
                      evt.preventDefault ();
              }
  
              return allow;
          }
      }
  )
0 - https://parsleyjs.org/