-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #913 from betagouv/make-options-required
Demander à sélectionner au moins une option à l’envoi d’une sollicitation
- Loading branch information
Showing
7 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ | |
// = require semantic-ui/dimmer | ||
|
||
// = require_tree ./application | ||
// = require_tree ./shared |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
// = require rails-ujs | ||
|
||
// = require_tree ./pages | ||
// = require_tree ./shared |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function checkboxes_require_one(selector, message) { | ||
let boxes_parent = document.querySelector(selector); | ||
|
||
function updateBoxesValidity() { | ||
let at_least_one_checked = !!boxes_parent.querySelector("input[type=checkbox]:checked"); | ||
let validity = at_least_one_checked ? "" : message; | ||
let boxes = boxes_parent.querySelectorAll("input[type=checkbox]"); | ||
boxes.forEach(function(box) { box.setCustomValidity(validity); }); | ||
} | ||
|
||
boxes_parent.addEventListener("click", function(event) { if (event.target.matches("input[type=checkbox]")) { updateBoxesValidity(); } }); | ||
|
||
updateBoxesValidity(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters