Tengo un test que quiero validar en el caso de que no se conteste alguna o ninguna pregunta, quiero que salga un mensaje de advertencia, pero no logro hacerlo, espero puedan ayudarme porque ya hace rato que estoy dando vuelta con esto y no logro nada.
Muchas gracias de antemano.
El test tiene el siguiente formato:
Código:
El formulario:var restotal = 0; function respuesta(oRad) { restotal = restotal + Number(oRad.value); } function total (){ if (restotal <= 5){ alert ("mensaje 1"); } if (restotal >= 6 && restotal <= 10){ alert ("mensaje 2"); } .... .... if (restotal >= 30){ alert ("mensaje n"); } restotal = 0; with (document.frm){ if (r1.checked) {r1.checked = false;} if (r2.checked) {r2.checked = false;} ... ... if (rn.checked) {rn.checked = false;} } }
Código HTML:
<tr> <td> <input type="radio" name="r1" value="0" onClick="respuesta(this)"> </td> <td> A) Respuesta 1</td> </tr> <tr> <td> <input type="radio" name="r1" value="1" onClick="respuesta(this)"> </td> <td> B) Respuesta 2</td> </tr> <tr> <td> <input type="radio" name="r1" value="2" onClick="respuesta(this)"> </td> <td> C) Respuesta 3</td> </tr> .... .... <td><input name="button" type="button" class="btform" onClick="total()" value="Resultado"></td>