tambien otr forma de validar con un scrip de java que se coloca en el head mira :
Código Javascript
:
Ver original<script language="javascript">
//Su explorador no soporta java o lo tiene deshabilitado; esta pagina necesita javascript para funcionar correctamente<!--
//Copyright © McAnam.com
// http://www.mcanam.com/articulos/JavaScript.php?id=30
function comprobar_formulario(oFormulario)
{
// Se comprueba si se pasa bien el objeto formulario
var iExiste = false;
var iCont = 0;
var sMensaje = "Por favor rellene todos los campos del formulario, faltan \n";
for (iCont = 0 ; iCont < document.forms.length ; iCont++)
{
if (document.forms[iCont] == oFormulario)
iExiste = true;
}
// No se ha pasado formulario, intentamos coger el primero del formulario
if (! iExiste)
{
oFormulario = document.forms[0];
if (! oFormulario)
{
alert("Formulario pasado incorrecto.\nNo se pudo encontrar formulario");
return false;
}
}
// Recorremos los elementos del formulario
for (iCont = 0 ; iCont < oFormulario.elements.length ; iCont++)
{
if (oFormulario.elements[iCont].type == "text" || oFormulario.elements[iCont].type == "radio")
{
if (oFormulario.elements[iCont].value.length == 0)
{
alert("Por favor rellene todos los campos del formulario, falta el campo " + oFormulario.elements[iCont].name);
oFormulario.elements[iCont].focus();
return false;
}
}
}
// Si hemos llegado aquí, todos los campos son correctos, enviamos el formulario
oFormulario.submit();
}
//-->
</script>
y este es mi formulario ....
Código HTML:
Ver original<form name="formulario1" id="formulario1" action="form.php" method="post"> <table align="center" width="95%"> <td><b>NOMBRE DE EL ESTABLECIMIENTO:
</b> <input type="text" name="establecimiento" size="96%"> <table align="center" width="95%"> <td width="50%"><b>RESPONSABLE:
</b> <input type="text" name="responsable" size="45%"> <td><b>CEDULA:
</b> <input type="text" name="cedula" size="30%"> <table align="center" width="95%"> <td width="50%"><b>DIRECCION:
</b> <input type="text" name="direccion" size="45%"> <td><b>BARRIO:
</b> <input type="text" name="barrio" size="53%"> <table align="center" width="95%"> <td><b>TELEFONO:
</b> <input type="text" name="telefono" size="20%"> <td><b>CELULAR:
</b> <input type="text" name="celular" size="20%"> <td><b>EMAIL:
</b> <input type="text" name="email" size="50%"> <table align="center" width="95%">
<td><input type="radio" name="actividad" value="alimetos y productos del campo">alimetos y productos del campo
<td><input type="radio" name="actividad" value="transporte">transporte
<td><input type="radio" name="actividad" value="maderas y muebles">madera y muebles
<td><input type="radio" name="actividad" value="combustible y mineria">combustible y mineria
<td><input type="radio" name="actividad" value="comercio">comercio
<td><input type="radio" name="actividad" value="vendedor ambulante">vendedor ambulante
<td><input type="radio" name="actividad" value="confecciones textiles,cuero,bisuteria">confecciones (textiles,cuero,bisuteria)
<td><input type="radio" name="actividad" value="restaurantes">restaurantes
<td><input type="radio" name="actividad" value="servicio profecionales">servicios profecionales
<td><input type="radio" name="actividad" value="artesanias">artesanias
<td><input type="radio" name="actividad" value="hoteles y turismo">hoteles y turismo
<td><input type="radio" name="actividad" value="ceramica y construccion">ceramica y ocnstruccion
<td><input type="radio" name="actividad" value="otros" checked="checked">otros
<table align="center" width="95%"> <td><b>DESCRIPCION ACTIVIDAD:
</b> <input type="text" name="descripcion" size="105%"> <table align="center" width="95%"> <td><b>MATRICULA:
</b> <input type="radio" name="matricula" value="si">Si
<input type="radio" name="matricula" value="no" checked="checked">No
<td><b>INDUSTRIA Y COMERCIO:
</b> <input type="radio" name="indycio" value="si">Si
<input type="radio" name="indycio" value="no" checked="checked">No
<td><b>RIESGO ALTO:
</b> <input type="radio" name="riesgo" value="si">Si
<input type="radio" name="riesgo" value="no" checked="checked">No
<table align="center" width="95%"> <td><b>HORARIO DE ATENCION:
<br><br> DIURNO:
</b> <input type="text" name="horariod" size="40%"> <b>NOCTURNO:
</b> <input type="text" name="horarion" size="40%"> <table align="center" width="95%"> <td><b>TIEMPO DE FUNCIONAMIENTO:
</b> <input type="text" name="tiempo" size="100%"> <table align="center" width="95%"> <td><b>OBSERVACIONES:
</b> <input type="text" name="observaciones" size="112%"> <table align="center" width="95%"> <td align="center"><input type="button" onclick="comprobar_formulario(this.form)" value="Enviar formulario"/>
espero que te haya servido de ayuda ...