aria-autocomplete icon indicating copy to clipboard operation
aria-autocomplete copied to clipboard

Handling required attribute / error message

Open mh-nichts opened this issue 1 year ago • 2 comments

Hello,

Thanks again for your plug-in, which we use on several projects.

We realized recently that if we use it on required fields (<select required>), it seems not to work correctly :

  • no required attribute on the generated input, so no screen-reader announcement that the field is indeed required
  • when trying to submit the form without filling that field, the browser wants to display the native HTML5 error message on the required select, but as it's invisible (with display none), it's not possible : so the form isn't submitted but there is no clue for the user to know what's wrong

Am I missing something in the process, is there a way to handle correctly that kind of required fields ?

mh-nichts avatar Jun 14 '23 12:06 mh-nichts

Hi @mh-nichts

The plugin intentionally doesn't try to infer any validation rules from the existing element(s) when you use it to progressively enhance them - it would be feasible to move things like the required attribute along, but it would be impossible to automatically copy any custom JS rules across. That's why so many callback methods are available - so that you can handle any validation needs yourself.

mynamesleon avatar Jun 14 '23 13:06 mynamesleon

Thank you for your answer, I understand. As a result, I used the onReady callback to handle that manually.

mh-nichts avatar Jun 20 '23 15:06 mh-nichts