clientside validation of checkboxes from PHP form 
Author Message
 clientside validation of checkboxes from PHP form

since PHP requires use of "[ ]" in multiple checkbox names, how does one do
clientside validation.
Javascript does not seem to want to accept "[ ]" in name reference


Sun, 07 Aug 2005 08:48:04 GMT  
 clientside validation of checkboxes from PHP form

Quote:

> since PHP requires use of "[ ]" in multiple checkbox names, how does one do
> clientside validation.
> Javascript does not seem to want to accept "[ ]" in name reference

Use this syntax to refer to the checkbox in JS:
document.forms['formname'].elements['checkboxname[]'];


Sun, 07 Aug 2005 01:52:08 GMT  
 clientside validation of checkboxes from PHP form
thanks !

that worked great



Sun, 07 Aug 2005 08:59:28 GMT  
 clientside validation of checkboxes from PHP form
You can use the following format for your checkboxes:

<input type="checkbox" name="list[]" id="list" value="a">
<input type="checkbox" name="list[]" id="list" value="b">
etc.

You can then examine the checkboxes in javascript using

if(typeof document.getElementById("list").length=='undefined')
{
// single checkbox
 if(document.getElementById("list").checked)
{

Quote:
}
}

else
{
 // multiple checkboxes
 for(n=0;n<document.getElementById("list").length;n++)
{
 if(document.getElementById("list")[n].checked)
{

Quote:
}
}
}



Quote:
> since PHP requires use of "[ ]" in multiple checkbox names, how does one
do
> clientside validation.
> Javascript does not seem to want to accept "[ ]" in name reference



Sun, 07 Aug 2005 17:44:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. PHP and forms, checked or not checkbox

2. newbie with a php validation form mail script problem

3. Verifying Checkbox Submissions - JScript/PHP Interaction Problem

4. Iterating through forms, but checkboxes are listed ?

5. Field Validation in a Form

6. Validation of FORM fields

7. HTML Form data validation with Object REXX (Windows)

8. Date validation of input from HTML form

9. Form validation q

10. form validation

11. Form Validation

12. Form validation and page navigation

 

 
Powered by phpBB® Forum Software