Foros del Web » Programando para Internet » Javascript »

validar radio button

Estas en el tema de validar radio button en el foro de Javascript en Foros del Web. holase que esta pregunta sera recontra conocida y recnotracontestada-Lei lospsot anteriores y trate aplicarlos a mi codgio pero no pude . como hago para validar ...
  #1 (permalink)  
Antiguo 24/11/2009, 20:56
 
Fecha de Ingreso: junio-2009
Ubicación: lima
Mensajes: 139
Antigüedad: 14 años, 10 meses
Puntos: 0
validar radio button

holase que esta pregunta sera recontra conocida y recnotracontestada-Lei lospsot anteriores y trate aplicarlos a mi codgio pero no pude . como hago para validar al radio button en mi codigo. requiero que me cuando presione registrar me diga "debe seleccionar una casilla", luego de seleccionar uno de los radio button poder recien pulsar registrar y asi pasar la pagina de resultados. no quieor queu na casiila esteseleccionada predeterminadamente , mas bien consistene que elusario eliga la casilla.


mi codigo este
Código PHP:
<?
session_start
();
include(
"include/bd.php");
include(
"include/functions.php");
$cod=$_GET['codigo'];
bd_connect();






?>


<html>
<head>
    <head>
    <title>REGISTRO</title>
        <h1 ALIGN="center"></H1>
            
    </script> 

</head>


[COLOR="blue"]<script language="JavaScript" type="text/javascript">
function validaBusq() {
    if(document.frmPersonal.codigo.value == "" ) {
        alert("Debe ingresar su codigo de acceso");
        document.frmPersonal.codigo.focus();
        return false;


       return true;
}   



</script>[/COLOR]</head>
        
<body>
<?include ("cabecera.php");?>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;obj.height=40;obj.wmode="transparent";showClock(obj);</script>


<br>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="contenido_result.php" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
    <td valign="top">
    
        <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td align="center"><p class="clsLblTituloPagina">Salida</p></td>
        </tr>
        <tr>
            <td><hr></td>
        </tr>
        </table><br>
            <table border="0" width="550" cellpadding="0" cellspacing="0" align="center">    
                <tr>
            <td>Código:</td>
            <td><input type="text" name="codigo" value="<?echo $_GET['codigo']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>


        </table>

                <h3 >Motivo de Salida:</h3><br>

[COLOR="Blue"]<script language="javascript" type="text/javascript"> 
valor = 0
function cambia(ra)
{
valor = ra.value
}
function validaBusq()
{
if (valor == 0) alert ("Debe seleccionar una casilla");

else {
return true;
}
</script>

<form action=salida.php method=post>[/COLOR]

<input type=radio name=tipo value=Comisión  />Comisión<br>
<input type=radio name=tipo value=Salud  />Salud<br>
<input type=radio name=tipo value=Asuntos Personales  />Asuntos_Personales<br>
<input type=radio name=tipo value=Salida Tarde  />Salida_Tarde<br>
<input type=radio name=tipo value=Salida Noche  />Salida_Noche<br>
<br>
<br>

<align="center"><INPUT TYPE=submit NAME=OK VALUE="Registrar"><BR>

</FORM></HTML>

<?php

if ($OK == "Registrar") {

echo 
"<B>motivo =</B>".$tipo."<br>";


}
?>

    
    

                </td>
        </tr>
        </table>
        
        <br>
        <table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
              <td>
                <!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0 
                    src="pagina_blanco.php" frameborder=1 
                    width=100% scrolling=no height="170"></iframe>-->
                    
                        </tr>
                        <tr>
                            <td colspan="5" height="1" bgcolor="#000000"></td>
                        </tr>
                                                </table>
                        
                    </td>
                </tr>
                </table>
                </div>
                <??>

            </td>
        </tr>
          </table>
        
    </td>
</tr>
</table>
<font style="font-size:15px;"><SCRIPT LANGUAGE="Javascript"><!--

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Domingo','Lunes','Martes'Miércoles','Jueves','Viernes','S&aacute;bado');

// Array list of months.
var months = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)    {
    return (number < 1000) ? number + 1900 : number;
                                }

// Join it all together
today =  days[now.getDay()] + " " +
              date + " " +
              months[now.getMonth()] + " " +               
                (fourdigits(now.getYear())) ;

// Print out the data.
document.write("" +today+ " ");
  
//--></SCRIPT></font></td> 

<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
<?include("pie.php");?>
</body>
Agradecere su ayuda
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:45.