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
you should have a label and a name attribute for all input types but buttons?
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
so yes you need a
name="someName"
to coincide with the labels*for="someName"
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
Always in a form
as they are form elements
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
does the action happen on submit or click of the input?
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
the benefits of form are really apparent for JS too when you start using formData() .
haven't come across that function yet, will keep it in mind, awesome