Skip to content Skip to sidebar Skip to footer

Php Checkbox Validation

I want to validate a PHP form with checkboxes preferably using Javascript or otherwise the client side code id: Branch Features:
Micro Centre:
echo"<pre>";
var_dump($_POST);
echo"</pre>";

And see what is coming there... Then just process it and that's it!

Solution 2:

You should be performing both client-side and server-side validation. Client side validation can be circumvented by simply disabling javascript.

If you are looking to enter the checkbox data into a database... First grab the data using either PHP's $_GET[] or $_POST[] array.

You can use the print_r() function to have a peak at what you're sending to the script.

Process this data, validate it, and insert into the database. The database code is so heavily reliant on DMS you are using that I won't bother giving specifics, but I suggest taking a look at the PDO.

I always say that the quality of answer is directly proportional to the quality of question. If you need further information, consider modifying your question to be more specific.

Solution 3:

Here's an attempt:

functionsubmit() {
 var checks = document.getElementsByName('features[]');
 var valid = false;   
 for (var check in checks)
        if (checks[check].checked) valid  = true;
 if (valid) 
     alert('submit');
 elsealert('invalid')
}

Demo

Post a Comment for "Php Checkbox Validation"