Jump to content

Simple validation problem


cody7

Recommended Posts

<script type="text/javascript">
function CheckForm() {
var count = 0;
//Please place the code here
}
</script>


<form name="myform" onSubmit="return CheckForm()">



<input type="checkbox" value="red" name="check1" />red<br />
<input type="checkbox" value="green" name="check2" />green<br />
<input type="checkbox" value="blue" name="check3" />blue<br />
<input type="checkbox" value="yellow" name="check4" />yellow<br />
.....
<input type="checkbox" value="gray" name="check100" />gray<p>


<input type="checkbox" value="1" name="other1" />1<br />
<input type="checkbox" value="2" name="other2" />2<br />
<input type="checkbox" value="3" name="other3" />3<br />


<input type="submit" value="Submit">

</form>

 

 

Ok heres what i need. please complete the form validation on top.

But :

1. checkbox name must not change (it must be check1 up to check100  or more)

2. the validation MUST be some kind of a loop checking every checkbox if they are checked so that i dont have to write hundred lines of codes just to check each.

3. when a particular  checkbox is checked. count will increment. count++;

4. take note of the other 3 checkboxes, they must NOT be included in the validation. only checkbox having a word "check" on their names will be validated

 

<input type="checkbox" value="1" name="other1" />1<br />
<input type="checkbox" value="2" name="other2" />2<br />
<input type="checkbox" value="3" name="other3" />3<br />

 

5. at the end of the validation maybe we can put an alert() containing the value of count

 

 

 

Thank for any help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.