Validar formulário em Javascript

Fevereiro 7, 2008

  1. <script language=”javascript” type=”text/javascript”>
  2. function valida(formulario){
  3.     var total = formulario.elements.length;
  4.    i = 0
  5.     while (i <= total)
  6.     {
  7.         if(formulario.elements[i].value == “”){
  8.         //    alert(”O campo ” + formulario.elements[i].name + “  continua vazio.”);
  9.             formulario.elements[i].focus();
  10.             return false;
  11.             break;
  12.             }
  13.        i++
  14.     }
  15. }
  16. </script>
  17. <form onSubmit=”return valida(this);”>

Entry Filed under: JavaScript, Programação Web. .

3 Comments Add your own

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Tópicos recentes

Comandos e Funções

mais acessados

Comentários

andre luiz em Validar formulário em Jav…
Rafaela Poiani em Validar formulário em Jav…
Vanessa em Validar formulário em Jav…