Mevrael / bunny

BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
https://bunnyjs.com
MIT License
486 stars 39 forks source link

Validating a yes/no radio group #25

Closed boyankostov closed 6 years ago

boyankostov commented 6 years ago

Hey, how do I setup a yes/no radio group? I tried placing required on both fields and separately on each one, to no avail. It only accepts Yes as a possible answer.

`

` image

Mevrael commented 6 years ago

Hi @boyankostov and thank you for your report.

From Web Standards perspective you should be able to put at least one required on any input in a group to make a whole group required, however, it is recommended to put required attribute on every input in a group.

Currently, yes, Bunny Validation is not taking this case of radio button group into account and thinks of every input as a separate input.

I will try to release an update this weekend.

Anyway from a UX perspective, it is not recommended to have a required radio button group without option selected by default, because user can not get back to initial state by unchecking the checked radio button.

I do prefer simple one checkbox for boolean inputs. Do you agree with terms? Then check a box, Do you want to receive email notifications? Then check the box and so on.

boyankostov commented 6 years ago

Thanks for the swift reply. I totally agree with you that it's a better UX approach to have an already selected option, but in this case I want to eliminate any bias and keep only one possible choice. Placing a single checkbox would also introduce bias in the results, cause this is not a turn on/off switch, but a question.

Thanks a bunch for taking this into account, I'll keep track of the thread.

Mevrael commented 6 years ago

Fixed in https://github.com/Mevrael/bunny/commit/90bea09545288e0f050b5c2a5f72c0ed7252b98e

Please let me know if issue is solved or you have any additional questions and if anything is fine, feel free to close this issue.

P.S. you may also join our Gitter chat https://gitter.im/bunny-js/Lobby

boyankostov commented 6 years ago

Thanks a bunch, it's working now!