<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> function ValidateCheckBox() { var selectedCheckBoxesValue = ''; $('#ValidateCheckBox').find("input:checkbox.CheckBoxClassName:checked").each(function (i, selected) { if (selectedCheckBoxesValue.length == 0) { selectedCheckBoxesValue += $(selected).val(); } else { selectedCheckBoxesValue += ',' + $(selected).val(); }}); // Here you also get all the comma separated values if you want else use below method for it if(selectedCheckBoxesValue.length == 0) { alert("Select atleast one checkbox"); } } </script> </head> <body> <div id="ValidateCheckBox" style="background-color:#0099FF; color:#FFFFFF; width:190;"> <table width="200" cellspacing="2" cellpadding="2"> <tr> <td><input type="checkbox" class="CheckBoxClassName"></td> <td><label>Checkbox 1</label></td> </tr> <tr> <td><input type="checkbox" class="CheckBoxClassName"></td> <td><label>Checkbox 2</label></td> </tr> <tr> <td><input type="checkbox" class="CheckBoxClassName"></td> <td><label>Checkbox 3</label></td> </tr> <tr> <td><input type="checkbox" class="CheckBoxClassName"></td> <td><label>Checkbox 4</label></td> </tr> <tr> <td><input type="checkbox" class="CheckBoxClassName"></td> <td><label>Checkbox 5</label></td> </tr> <tr> <td colspan="2"><input type="button" onClick="ValidateCheckBox();" value="Validate checkbox"></td> </tr> </table> </div> </body> </html>
Subscribe Now
Popular Posts
Blog I Read
Coding Cluster
Multiple checkbox validation in asp .net mvc3 using jquery
Friday
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Share your thoughts here...