ho questo form:
quando faccio il submit richiamo questa funzioncina JS per il controllo dei valori:codice:<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="form_entrate" onsubmit="return valida(this.name);"> <fieldset> <legend>Aggiungi entrata</legend> <table> <tr> <td>Valore:</td> <td><input type="text" name="entrata_valore" value="" /></td> </tr> <tr> <td>Causale:</td> <td> <select name="entrata_causale"> <option value="*">*</option> <?php foreach (selectCausale() as $value) { echo "<option value='" . $value['causale_id'] . "'>" . $value['causale_nome'] . "</option>"; } ?> </select> </td> </tr> <tr> <td>Conto:</td> <td> <select name="entrata_conto"> <option value="*">*</option> <?php foreach (selectConto() as $value) { echo "<option value='" . $value['conto_id'] . "'>" . $value['conto_nome'] . "</option>"; } ?> </select> </td> </tr> <!-- <tr> <td>Data:</td> <td><input type="text" name="entrata_data" value="" /></td> </tr>--> <tr> <td>Note:</td> <td><input type="text" name="entrata_note" value="" /></td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" name="btn_entrata" /></td> </tr> </table> </fieldset> </form>
il problema è che nn succede nulla.codice:<script type="text/javascript"> function valida(modulo) { var valore = document.modulo.entrata_valore.value; var causale = document.modulo.entrata_causale.options[document.modulo.entrata_causale.selectedIndex].value; var conto = document.modulo.entrata_conto.options[document.modulo.entrata_conto.selectedIndex].value; if(valore == "" || causale == "*" || conto == "*") { alert("Valore, causale e conto sono obbligatori"); return false; } } </script>
dove sto sbagliando??

Rispondi quotando