Advertisement
Guest User

JSC31 valida1

a guest
May 27th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <HTML>
  2. <HEAD>
  3.  
  4. <SCRIPT>
  5.  
  6. // script jsc31 valida 1
  7.  
  8. // Este script valida basicamente um form nos seguintes aspetos:
  9. //
  10. // O campo nome tem que estar preenchido
  11.  
  12. // O campo Numero BI tem que estar preenchido com pelo menos 8 números
  13. // e não pode conter caracteres alfabéticos
  14.  
  15. // O campo correio tem que estar preenchido e conter o caracter @
  16.  
  17.     function validar()
  18.     {
  19.         if (document.ficha.nome.value.length == 0)
  20.         {
  21.             alert("Faltou o nome");
  22.  
  23.             return false;
  24.         }
  25.            
  26.         if ( isNaN(document.ficha.numbi.value) )
  27.         {
  28.             alert("O BI deve conter apenas algarisnmos");
  29.                
  30.             return false;
  31.         }
  32.  
  33.         else if (document.ficha.numbi.value.length < 8)
  34.         {
  35.             alert("Insira todos os numeros do BI");
  36.                
  37.             return false;
  38.         }
  39.      
  40.  
  41.         if (document.ficha.correio.value.indexOf("@") == -1)
  42.         {
  43.             alert("Email invalido");
  44.                
  45.             return false;
  46.         }
  47.  
  48.         return true;   
  49.        
  50.     }// fecha func
  51.  
  52.  
  53.  
  54. </SCRIPT>
  55.  
  56. </HEAD>
  57.  
  58. <BODY onLoad="document.ficha.nome.focus()">
  59.  
  60. <form name="ficha" method="post" action="mailto:josecamaraabc@serv.com"
  61.  
  62.         onSubmit="return validar();">
  63.  
  64. Nome: <input type="text" name="nome" size="20" maxlength="30">
  65. <BR>
  66.  
  67. Numero BI: <input type="text" name="numbi" size="10" maxlength="10">
  68. <BR>
  69.  
  70. Correio Eletronico: <input type="text" name="correio" size="20" maxlength="20">
  71. <BR>
  72.  
  73. <input type="Reset" value="Limpar">
  74. <BR>
  75.  
  76. <input type="Submit" value="Enviar">
  77. <BR>
  78.  
  79. </BODY>
  80. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement