snippet library logo
in category
Javascript / Forms / Check only two checkboxes....
Snippet details
ID: 480
Viewed: 1285
Added: 2002-09-03
Version:
View Demo

User Rated at:
Rate This:
Snippets in this catagory         
Show Printable Version
Limits a user to only selecting two checkboxes

General Details
Snippet uploaded by: Dr. Web
Email : harbor31@hotmail.com
Snippet By: Dr. Web

<!---Head--->
<SCRIPT LANGUAGE="javascript">

function KeepCount() {

var NewCount = 0

if (document.joe.dog.checked)
{NewCount = NewCount + 1}

if (document.joe.cat.checked)
{NewCount = NewCount + 1}

if (document.joe.pig.checked)
{NewCount = NewCount + 1}

if (document.joe.ferret.checked)
{NewCount = NewCount + 1}

if (document.joe.hampster.checked)
{NewCount = NewCount + 1}

if (NewCount == 3)
{
alert('Pick Just Two Please')
document.joe; return false;
}

</SCRIPT> 

<!---Body--->


<FORM NAME="joe">
<b>Pick Only Two Please!</b> 

<INPUT TYPE="checkbox" NAME="dog" 
onClick="return KeepCount()"> Dog

<INPUT TYPE="checkbox" NAME="cat" 
onClick="return KeepCount()"> Cat

<INPUT TYPE="checkbox" NAME="pig" 
onClick="return KeepCount()"> Pig

<INPUT TYPE="checkbox" NAME="ferret" 
onClick="return KeepCount()"> Ferret

<INPUT TYPE="checkbox" NAME="hampster" 
onClick="return KeepCount()"> Hampster

</FORM> 

</body>
</html>




No Reviews to show


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Subject:

Reviewed By:

Write a review:





Terms of Conditions
Powered By
Avian Hosting
© 2005 snippetlibrary.com All Rights Reserved.