add validation for empty motivation field with javascript

This commit is contained in:
Lisa Durand 2023-07-05 18:18:40 +02:00
parent a694d65911
commit 890e00f915
2 changed files with 33 additions and 2 deletions

View file

@ -58,6 +58,37 @@ export class BatchOperationController extends ApplicationController {
}
}
onSubmitInstruction(event: { srcElement: HTMLInputElement }) {
const field_refuse = document.querySelector<HTMLInputElement>(
'.js_batch_operation_motivation_refuse'
);
const field_without_continuation = document.querySelector<HTMLInputElement>(
'.js_batch_operation_motivation_without-continuation'
);
if (field_refuse != null) {
if (event.srcElement.value == 'refuser' && field_refuse.value == '') {
field_refuse.setCustomValidity('La motivation doit être remplie');
} else {
field_refuse.setCustomValidity('');
}
}
if (field_without_continuation != null) {
if (
event.srcElement.value == 'classer_sans_suite' &&
field_without_continuation.value == ''
) {
field_without_continuation.setCustomValidity(
'La motivation doit être remplie'
);
} else {
field_without_continuation.setCustomValidity('');
}
}
}
onDeleteSelection(event: { preventDefault: () => void }) {
event.preventDefault();
emptyCheckboxes();