Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
4,649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1.  
  2. <script type="text/javascript">
  3.  
  4. function checkboxlimit(checkgroup, limit){
  5. for (var i=0; i<checkgroup.length; i++){
  6. checkgroup[i].onclick=function(){
  7. var checkedcount=0
  8. for (var i=0; i<checkgroup.length; i++)
  9. checkedcount+=(checkgroup[i].checked)? 1 : 0
  10. if (checkedcount>limit){
  11. alert("You can select a maximum of "+limit+" boxes.")
  12. this.checked=false
  13. }
  14. }
  15. }
  16. }
  17.  
  18. checkboxlimit(document.forms.name-of-your-form['field-name[]'], 5);
  19. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement