Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Validation

Status
Not open for further replies.

megaladon

Programmer
Sep 27, 2002
14
CA
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.
admin@onpntwebdesigns.com
 
If both are checked I want an alert telling the user to only select one check box.
 
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=&quot;radio&quot; name=&quot;helpful_&quot; value=&quot;yes&quot; checked> Yes
<input type=&quot;radio&quot; name=&quot;helpful_&quot; value=&quot;no&quot;> No

I think that would work for what you are doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top