tabindex attribute on radio input

It seems like we need to have a name attribute on an input of type radio, otherwise, we can't tap through them, is this correct or am I doing something wrong?
10 Replies
b1mind
b1mind2y ago
you should have a label and a name attribute for all input types but buttons?
NazCodeland
NazCodelandOP2y ago
I had 4 input fields, and devTools complained they didn't have labels so I gave them labels but, I also put them in a form element but I don't think I had to do that
b1mind
b1mind2y ago
so yes you need a name="someName" to coincide with the labels*for="someName"
NazCodeland
NazCodelandOP2y ago
ok, got it, thanks, does it make sense for input fields to not be within a form element? I had them inside of a regular div, but changed it to form
b1mind
b1mind2y ago
Always in a form as they are form elements
NazCodeland
NazCodelandOP2y ago
even if it's just for styling purposes that you are using those inputfields hmm, that might give off the wrong idea, what I mean to say is
b1mind
b1mind2y ago
does the action happen on submit or click of the input?
NazCodeland
NazCodelandOP2y ago
these 4 input fields, they are being used as themes, when you click on one input radio field, it will toggle that theme etc it happens on click and on keypress I originally had a button for this but the framework I am using, Svelte kit has some nice directives where you can do bind:value={someVar} and this way, when you click on an input field, the input fields value is derived to the variable but, I think I got my answer, they belong in a form element that works, thank you @b1mind
b1mind
b1mind2y ago
the benefits of form are really apparent for JS too when you start using formData() .
NazCodeland
NazCodelandOP2y ago
haven't come across that function yet, will keep it in mind, awesome
Want results from more Discord servers?
Add your server