demarches-normaliennes/app/javascript/controllers/radio_enabled_submit_controller.tsx

15 lines
358 B
TypeScript
Raw Normal View History

2023-04-27 10:10:57 +02:00
import { Controller } from '@hotwired/stimulus';
export class RadioEnabledSubmitController extends Controller {
static targets = ['submit'];
declare readonly submitTarget: HTMLButtonElement;
click() {
if (
this.element.querySelectorAll('input[type="radio"]:checked').length > 0
) {
this.submitTarget.disabled = false;
}
}
}