![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
21/02/2011, 16:40
|
![Avatar de _cronos2](http://static.forosdelweb.com/customavatars/avatar357240_2.gif) | 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 |