Ver Mensaje Individual
  #10 (permalink)  
Antiguo 21/02/2011, 16:40
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 14 años, 8 meses
Puntos: 310
Respuesta: Problema con validar campos de formulario

Código:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script> /* Abrimos etiqueta de código */
function validar_formulario(){ /* Abrimos la función validar_formulario */
if (document.form1.titulo.value.length==0){
alert('Debe ingresar un titulo')
document.form1.titulo.focus()
return !!0;
}
}
</script>
</head>
<body>
<form name="form1" action="procesanoticia.php" method="post" onsubmit='return validar_formulario()'> 
Título noticia:<br> 
<input type="text" name="titulo"><br> 
Autor:<br> 
<input type="text" name="autor"><br> 
Categoría:<br> 
<input type="text" name="categoria"><br> 
Escriba el articulo<br> 
<textarea name="articulo" cols="50" rows="10"></textarea><br> 
<input type="submit" value="Publicar" />
</form>
</body>
</html>
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red