Checkbox validation in javascript

Checkbox and radio button validation in javascript:

function validateCourse(){
count = 0; gend = 0;
len = document.testForm.elements.length;
elt = document.testForm.elements[i];
if(elt.type == 'checkbox' &&'course' && elt.checked){
if(elt.type == 'radio' &&'gender' && elt.checked){
        alert("Please Select 3 Courses");
    if(gend == 0){
        alert("Select Gender Field");
<form name='testForm'>
<big> Subject You Know</big><br>
<input type='checkbox' name='course' value='c'> C-Language <br>
<input type='checkbox' name='course' value='j' > Joomla <br>
<input type='checkbox' name='course' value='p' > PHP <br>
<input type='checkbox' name='course' value='s' > SAP <br>
<input type='checkbox' name='course' value='d' > Drupal <br>
<input type='checkbox' name='course' value='m' > MySQL <br><br>
<input type='radio' name='gender' value='m'> Male <input type='radio' name='gender' value='f'> Female <br><br>
<input type='button' name='coursecount' value='Validate !' onclick="javascript:validateCourse();">





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s