Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/02/2011, 10:35
matiasbmx
 
Fecha de Ingreso: febrero-2011
Mensajes: 124
Antigüedad: 14 años, 1 mes
Puntos: 4
Problema con validar campos de formulario

Buenas, he intentado insertar unaa funcion para validar si los campos de texto estan vacios, no te deje publicar el post, pero no valida, lo manda igual
aqui el code:
Código PHP:
<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>
<
form name="form1" action="procesanoticia.php" method="post"
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" onclick="validar_formulario()" />
</
form>  
</
html