This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 1st, 2014  |  syntax: None  |  size: 0.49 KB  |  views: 222  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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>
clone this paste RAW Paste Data