cody7 Posted April 12, 2007 Share Posted April 12, 2007 <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 Quote Link to comment Share on other sites More sharing options...
fenway Posted April 12, 2007 Share Posted April 12, 2007 I don't know who you think "we" is, no one is going to write this code for you... Basically, loop through all of the form elements, if it's a checkbox and starts with "check", increment a counter. That's it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.