I'm not able to check if at least one checkbox was checked before submitting to form.
I saw that you have some questions similar to mine, but none of the solutions worked for me
I used the following code and it is not working:
$("#funcoes_cursos").submit(function(){
var cursos = $("#funcoes_cursos input[name='cursos[]']").val();
if(cursos == "" || cursos === undefined){
alert('Selecione um ou mais cursos para deletar');
return false;
}else {
if( !(confirm("Ao deletar um curso, todos os dados relacionados a ele também serão deletados. Deseja realmente deletar o curso?")) ) {
return false;
}
}
});
The inputs are in the format:
<input type="checkbox" name="cursos[]" value="">
My idea is that before sending the form to the page that deletes the selected courses, it checks that at least one course is selected. But the way it is it does not take the input value.