Click to See Complete Forum and Search --> : Validating an array of checkbox in a form


BareFoot
October 1st, 2004, 04:03 AM
I'm a newbie in Javascript. I am currently coding in php. I have a form in html and I want to validate an array of checkboxes before submitting the form. The usual way of validating checkboxes doesn't work cos i'm using array for this set of checkbox.

Any advice is very much appreciated. Thank you in advance.

The code extract for the HTML is as following:

<tr>
<td colspan=2> 5. Will you be providing us any content or material for this project? Please select all that apply.</td></tr>
<tr> <td>&nbsp</td><td> <input type="checkbox" name="material[]" value="text">Yes, text content</td></tr>
<tr> <td>&nbsp</td><td> <input type="checkbox" name="material[]" value="graphics or pictures">Yes, graphics or pictures</td></tr>
<tr> <td>&nbsp</td><td> <input type="checkbox" name="material[]" value="streaming audio/video">Yes, streaming audio/video files</td></tr>
<tr> <td>&nbsp</td><td> <input type="checkbox" name="C1" value="zero">No, not at all.</td>
</tr>

I want to validate the material[] checkboxes. Please help!

-------------~Philosophy~----------------------
I shall pass this way but once, any good I can do,
any kindness I can show, let me do it now,
for I shall not pass this way again.

cjard
October 2nd, 2004, 07:44 PM
javascript queries belong in the scripting forum.. cheers

PallaviDalvi
October 4th, 2004, 04:13 AM
When u are validating in javascript u work on the id of the element. in this case u need to assign the checkboxes ids...and then the normal way of validating shud work. in PHP u need the names of the elements. and so material[] wud be of importance there.
i think this shud help u...if not get back!