kushal33

checkbox group check uncheck validation using jquery

May 23rd, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. $( document ).ready(function() {
  2. $('.checkbox').change(function() {
  3. if($(this).is(":checked")) {
  4. var current_group = $(this).attr("group");
  5.  
  6. jQuery('.checkbox').each(function() {
  7. var currentElement = $(this);
  8. if(currentElement.attr("group") != current_group) {
  9. currentElement.prop("disabled", true);
  10. }
  11. });
  12.  
  13. }
  14.  
  15. if(!$(this).is(":checked")) {
  16. jQuery('.checkbox').each(function() {
  17. var currentElement = $(this);
  18.  
  19. currentElement.prop("disabled", false);
  20. currentElement.prop("checked", false);
  21. });
  22. }
  23.  
  24.  
  25. });
  26. });
Add Comment
Please, Sign In to add comment