473,385 Members | 1,707 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,385 software developers and data experts.

validate checkbox

102 100+
how do i make sure that those 4 checkbox are checked before i send the page..??
Jun 27 '07 #1
1 1398
iam_clint
1,208 Expert 1GB
I would do it something like this.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <script>
  5. function validate() {
  6. var cb = document.getElementsByName("check");
  7. for (i=0; i<cb.length; i++) {
  8.  if (cb[i].checked == false) { alert("Please put a checkmark in all check boxes."); return false; }
  9. }
  10. return true;
  11. }
  12. </script>
  13.  
  14. <form name="myform" action="dosomething.asp" method="POST" onsubmit="return validate();">
  15. <input type="checkbox" name="check">check box 1<br>
  16. <input type="checkbox" name="check">check box 2<br>
  17. <input type="checkbox" name="check">check box 3<br>
  18. <input type="checkbox" name="check">check box 4<br>
  19. <input type="submit" value="Submit" name="submit1">
  20. </form>
  21. </body>
  22. </html>
  23.  
Jun 27 '07 #2

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

Similar topics

0
by: Kumar | last post by:
Hi , I am using the article code shown in below url: http://www.codeproject.com/aspnet/xmlxsltransformer.asp?df=100&forumid=118504&select=1170328 This article is very cool feature. I...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
1
by: jayparaiso | last post by:
Hi! How to validate check box and drop down menu in one form?
5
by: timothy.pollard | last post by:
Hi I'm having a bit of bother trying to make a questionnaire do what I want it to. I have put it up on www.web-iq.co.uk/test.htm. Basically the user of the final form (when I've tarted it up)...
1
by: Scott | last post by:
I'm trying to validate a checkbox below on Sumbit. If the checkbox named "myForm.myCheckBox" isn't checked, then the code in CODE 1 displays False, which is correct. However, when I test that...
2
by: Zvonko Bičkup | last post by:
Hi! I have 5 checkboxes with the same name: <input type="checkbox" name="check" value="XYZ" /> <input type="checkbox" name="check" value="ZXY" /> <input type="checkbox" name="check" value="MHG"...
1
by: anilareddy | last post by:
I have an application like this. I need to validate the start time in 2nd row against the start row in first row. I mean The start time value entered in the second row must not b the value entered in...
1
by: mbarnhizer | last post by:
Hello All, Trying to figure out how to validate a series of questions on an online test. I am thinking that VB or Javascript is the best route, but your input may make a difference. The site i...
4
by: CF FAN | last post by:
I want to validate this two checkbox variables on an action page and also an update page <cfinput type="checkbox" name="gender"checked> </label></td> <td>Female</td> ...
5
by: lolodede | last post by:
i would like to make sure user at least one checkbox and if it select otherand need to make sure to write something in text box <?php $name = 0; $cusID=0; $hobbies =0 ; if (isset ($_POST)) {...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.