JSFiddle - React, Tailwind, and code Playground
by dorathoto
HTML
<form>
<input type="checkbox" name="chk_IDDel" id="chk_IDDel" value='1' />
<br>
<input type="checkbox" name="chk_IDDel" id="chk_IDDel" value='2'/>
<br>
<input type="checkbox" name="chk_IDDel" id="chk_IDDel" value='3' />
<br>
<input type="checkbox" name="chk_IDDel" id="chk_IDDel" value='4' />
<br><br>
<input type="submit" value="deletar registro" id="btn_Deletar" class="btn btn-danger" disabled="true" />
</form>
JavaScript
$(function () {
$("[name='chk_IDDel']").change(function () {
var disabled = true;
$("[name='chk_IDDel']").each(function () {
if ($(this).is(':checked')) {
disabled = false;
if ($("input[name=chk_IDDel]:checked").length > 1) {
document.getElementById("btn_Deletar").value = 'Deletar imóveis';
}
else {
document.getElementById("btn_Deletar").value = 'Deletar imóvel'
}
}
});
$('#btn_Deletar').prop("disabled", disabled);
});
$("#btn_Deletar").click(function () {
var confirma = prompt("digite a palavra 'confirmar' para deletar", "");
if (confirma.toUpperCase() == "CONFIRMAR") {
document.all.submit();
}
else {
return false;
}
});
});