hola a todos tengo un problemita con la validacion del formulario q es cuando le doy clik al boton de GENERAR REPORTE si no hay un radio marcado tiene q aparecerme un mensaje q tiene q elegir un radio y cuando elijo uno y le doy al boton el msj me sale pero le doy aceptar y me dentra a la pagina eso no me deberia pasar ayudamen
aqui les dejo mi codigo:
Código HTML:
<head>
<SCRIPT LANGUAGE="JavaScript">
function validarFormulario() {
var form = document.formulario;
var s = "no";
for ( var i = 0; i < form.salario.length; i++ ) {
if ( form.salario.checked ) {
s= "si";
break;
}
}
if ( s == "no" ){
alert( "Debe seleccionar una opcion" ) ;
}
}
</SCRIPT>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<table width="100%" border="0" cellspacing="0" cellpadding="0" center>
<tr>
<td width="254"><div align="left"><img src="imagenes/top21.jpg" width="254" height="75" /></div></td>
<td width="" align="right" valign="bottom" class="mainhead Estilo74" title="Consulta Recibo de pago"><div align="center"><center><h3><font face="arial"><font color="#317bae">Consulta de Empleado </font></div></td>
<td width="300" title="Consulta Recibo de pago"><div align="right"><img src="imagenes/nomsistema.jpg" width="329" height="75" border="0" /></div></td>
<td width="80" title="Gerencia de Automatización de Servicios"><div align="right"><img src="imagenes/gas.jpg" width="80" height="75" border="0" /></div></td>
</tr>
<tr>
<td colspan="4" style="background-color:#317bae; filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#317bae', startColorstr='#ffffff', gradientType='1')"> </td>
</tr>
</table>
<table width="200" border="0" align="right">
<tr>
<td><a href="menupri.php"><h4 align="center">Volver</h4></a></td>
</tr>
</table>
<br />
<br />
<form method="post" name="formulario" action="siguiente.php?cedula=<?php echo $row_constancia['cedula'];?>" >
<br />
<br />
<br />
<table width="48%" border="0" align="center" class="Estilo9">
<tr>
<th scope="col" colspan="0" align="center" class="subtitulo2" bgcolor="#317bae"><p align="center"> Elija la Siguente Opcion opción: </p></th>
</tr>
<tr>
<th width="0%" height="0"scope="row" ><label>
<input name="salario" type="radio" value="1"/>
Sin Salario</label> </th>
<th width="0%"scope="row" ><label>
<input name="salario" type="radio" value="2"/>
Con Salario Basico</label> </th>
<th width="0%"scope="row"><label>
<?php if (($anio > 1) or(($tipopersonal!=05) and ($tipopersonal!=06) and ($tipopersonal!=07))){
echo "<input name='salario' type='radio' value='3'/>
Con Salario Integral Estimado";} ?></label> </th>
</tr>
<tr>
<th height="38" colspan="0" align="center" bgcolor="#317bae" class="subtitulo2"><p align="center"><strong>Si quiere con Cesta Tiket Elija la Siguente Opcion opción: </p>
</tr>
<tr>
<th height="25" colspan="0" align="center" class="subtitulo2"><p align="center"><strong><label>
<input type="checkbox" name="ticket" value="1"/>
Con Cesta Tiket</label></th>
</tr>
</table>
<br />
<br />
<table align="center">
<p>
<th align="center"><label>
<input type="submit" name="Submit" value="GENERAR REPORTE" onClick="validarFormulario()" />
</label></th>
</p>
</table>
</form>
</body>
</head>
</html>