I am trying to validated two checkboxes with different names. I want to verify that at least one is checked or if both are checked. Then give an alert and set focus on one of the checkboxes.
on what condition tells which checkbox to be checked after the condition of both being checked was found? A language that doesn't affect the way you think about programming is not worth knowing.
Use radio buttons and in the input tag put selected. This will automatically select the one you place the option in and as you know, onlyone radio button can be selected at a time. This will gaurantee one and only one is checked.
This form is being insert into a db and there is a loop in my insert page that loops through the fieldnames of the form. Can I have radio buttons with different names and still only be able to select one? Can radio buttons be assigned a value of "Yes" which I need to submit to my db?
You assign each button a name and that puts them into the category, you then assign each a value. e.x.:
Has this site been helpful?
<input type="radio" name="helpful_" value="yes" checked> Yes
<input type="radio" name="helpful_" value="no"> No
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.