Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <div class="form-group" id="productOptionGroup">
  2. <label for="productOption[]">Opcje towaru</label>
  3. <div class="checkbox">
  4. <label class="checkbox-inline">
  5. <input name="productOption[]" type="checkbox" id="inlineCheckbox1" value="Opcja1" onchange="ValidationProductOption()">Opcja 1
  6. </label>
  7. <label class="checkbox-inline">
  8. <input name="productOption[]" type="checkbox" id="inlineCheckbox2" value="Opcja2" onchange="ValidationProductOption()">Opcja 2
  9. </label>
  10. <label class="checkbox-inline">
  11. <input name="productOption[]" type="checkbox" id="inlineCheckbox3" value="Opcja3" onchange="ValidationProductOption()">Opcja 3
  12. </label>
  13. <label class="checkbox-inline">
  14. <input name="productOption[]" type="checkbox" id="inlineCheckbox4" value="Opcja4" onchange="ValidationProductOption()">Opcja 4
  15. </label>
  16. <label class="checkbox-inline">
  17. <input name="productOption[]" type="checkbox" id="inlineCheckbox5" value="Opcja5" onchange="ValidationProductOption()">Opcja 5
  18. </label>
  19. </div>
  20. </div>
  21.  
  22.  
  23.  
  24.  
  25. function ValidationProductOption()
  26. {
  27. var checkBox = document.getElementsByTagName("productOption[]");
  28. var counter = 0;
  29.  
  30. for (var i = 0; i< 5; i++)
  31. {
  32. if(document.forms["form"]["productOption[]"][i].checked)
  33. {
  34. counter++;
  35. }
  36. }
  37.  
  38. if ( counter < 2)
  39. {
  40. var input = document.getElementById("productOptionGroup");
  41. var content = document.createTextNode("Zaznacz minimum 2 opcje");
  42. errorFunction(input, content);
  43. return false;
  44. }
  45. else
  46. {
  47. var input = document.getElementById("productOptionGroup");
  48. error = document.getElementById("error");
  49. if (input.lastChild == error)
  50. {
  51. input.removeChild(error);
  52. }
  53. return true;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement