fix validity

This commit is contained in:
Adrien MALINGREY 2020-10-15 03:48:10 +02:00
parent b6efe967ea
commit a67a38c92f

View File

@ -104,7 +104,7 @@ function refresh(box) {
for (neighbour1 of box.neighbourhood) { for (neighbour1 of box.neighbourhood) {
neighbour1.setCustomValidity("") neighbour1.setCustomValidity("")
if (neighbour1.value.length) { if (neighbour1.value.length) {
if (neighbour1.candidates.size) { if (neighbour1.value) {
for (area of [ for (area of [
{name: "région", neighbours: regions[neighbour1.regionId]}, {name: "région", neighbours: regions[neighbour1.regionId]},
{name: "ligne", neighbours: rows[neighbour1.rowId]}, {name: "ligne", neighbours: rows[neighbour1.rowId]},
@ -116,11 +116,12 @@ function refresh(box) {
neighbour.setCustomValidity(`Il y a un autre ${neighbour.value} dans cette ${area.name}.`) neighbour.setCustomValidity(`Il y a un autre ${neighbour.value} dans cette ${area.name}.`)
} }
} }
} } else {
} else if (neighbour1.candidates.size == 0) { if (neighbour1.candidates.size == 0)
neighbour1.setCustomValidity("Aucun value possible !") neighbour1.setCustomValidity("Aucun value possible !")
} }
} }
}
if (box.form.checkValidity()) { // Correct grid if (box.form.checkValidity()) { // Correct grid
if (boxes.filter(box => box.value == "").length == 0) { if (boxes.filter(box => box.value == "").length == 0) {