Ho questo form dal quale devo selezionare almeno un checkbox e di cui faccio il submit tramite un link. Vorrei però che il submit avenisse esclusivamente se almeno uno dei checkbox sia selezionato:
Codice PHP:
<form class="form" method="post" name="frm_ospiti" id="frm_ospiti" action="ospiti_registrazione.php">
<table class="table" cellspacing="0" width="100%">
<thead>
<tr>
<th class="black-cell"><span class="loading"></span></th>
<th scope="col">
Azienda
</th>
<th scope="col">
Ospite
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" value="3"></th>
<td>Eurogroup</td>
<td>Covassin Denis</td>
</tr><tr>
<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" value="4"></th>
<td>Eurogroup</td>
<td>Della Silvestra Andrea</td>
</tr><tr>
<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" value="1"></th>
<td>Idealogica</td>
<td>Ciccone Alessandro</td>
</tr><tr>
<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" value="5"></th>
<td>SMC</td>
<td>Andrea Cisolla</td>
</tr><tr>
<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" value="2"></th>
<td>SMC</td>
<td>Fabrizio Piccolo</td>
</tr> </tbody>
</table>
</div>
<div class="block-footer no-margin">
[img]../images/icons/fugue/arrow-curve-000-left.png[/img]
[url="javascript:void(0);"]Tutti[/url]
[url="javascript:void(0);"]Nessuno[/url]
<span class="sep"></span>
[url="javascript:void(0);"][img]../images/icons/fugue/tick-circle.png[/img] Registra[/url]
</div>
</form>
Questo il javascript per attivare i pulsanti:
Codice PHP:
<script type="text/javascript">
$(document).ready(function() {
$('#btn_seleziona').click(function() {
$("th.table-check-cell :checkbox:enabled").attr({ checked: "checked" });
});
$('#btn_deseleziona').click(function() {
$("th.table-check-cell :checkbox:checked").attr({ checked: "" });
});
$('#btn_registra').click(function() {
$('#frm_ospiti').submit();
});
});
</script>
In pratica nella parte del #btn_registra dovrei permettere il submit solo nel caso in cui almeno un checkbox sia selezionato, ma non ho idea di come fare...