473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Check box validation

18
hi all,
i am having a page where there are some checkboxes in it. i cant give exact number because i am getting that from database. so now if the user didnt check atleast one check box i need to get a popup. so can any one help me please..its urgent..
Thank u..
Expand|Select|Wrap|Line Numbers
  1. <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
  2.     <tr>
  3.         <th></th>
  4.         <th style="color: navy;">Userid</th>
  5.         <th style="color: navy;">Username</th>
  6.  
  7.     </tr>
  8.     <?php
  9.     $sno=1;
  10.     while($row=mysql_fetch_array($result2, MYSQL_ASSOC)){
  11.     ?>
  12.      <tr>
  13. <td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['userid']; ?>"></td>
  14. <td><? echo $row['userid']; ?></td>
  15. <td><? echo $row['username'];?></td>
  16. </tr>
  17. <?php
  18.     $sno=$sno+1;
  19. }
  20. ?>
  21.     </table>
Jun 3 '10 #1
1 1058
Dormilich
8,658 Expert Mod 8TB
a popup is a client-side action, thus PHP can’t be (directly) involved.

to check whether no checkbox was selected, loop over all checkboxes and test for the .checked property.

Expand|Select|Wrap|Line Numbers
  1. // returns true if at least one box is checked, otherwise false
  2. function checkBox()
  3. {
  4.     var i, list = document.forms[0]["checkbox[]"];
  5.     for (i = list.length; i--;) {
  6.         if (list[i].checked) {
  7.             return true;
  8.         }
  9.     }
  10.     return false;
  11. }
Jun 3 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
1
by: betterdie | last post by:
Hi all; I code Perl for CGI, I using regular expression to check the validation of user input, because the form is small and it run only from my own computer, anyways if many people using my...
2
by: Hawksey | last post by:
Can anyone tell me what is potentially dangerous with the following combination of letters "OnU="
5
by: rodchar | last post by:
hey all, in my page load i'm attaching a javascript confirm message to my save button. my problem is i have some client side validation which uses a Custom Validator web control and when i make...
6
by: serge calderara | last post by:
Dear all, I have read that ASP.NET does double user input validation of control when they are place on the page. Once on teh client side and again from server side right ? Could explain how...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
1
by: John Chan | last post by:
Hi, Im doing a maintenance application in ajax and coldfusion at work on IE6 exclusively. I have a save button on each form and i have to do various validations server side and on client side...
6
by: Jon Paal | last post by:
validation doesn't fire what's missing ????? /////// ---- code -----/////////////////////////// Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) 'Handles...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
6
by: lucoin | last post by:
Hello guys, I met a problem about php and javascipt For a tickets booking system, when a customer search for flights from one city, so in the data base there should be many routes to different...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.