Fonte: www.scriptbrasil.com
<html>
<head>
<title>ScriptBrasil - Js
Validação</title>
<script Language="JavaScript">
/*
##############################
#
#
#
ScriptBrasil
#
#http://www.scriptbrasil.com/#
#
#
##############################
*/
function checa_formulario(icqlist){
if (icqlist.nick.value == ""){
alert("Por Favor Coloque Seu Nick !!!");
icqlist.nick.focus();
return (false);
}
if (icqlist.email.value == ""){
alert("O Campo E-mail está Vazio !!!");
icqlist.email.focus();
return (false);
}
if (icqlist.email.value.indexOf('@', 0) == -1){
alert("O E-mail é Ivalido !!!");
icqlist.email.focus();
return (false);
}
if (icqlist.icq.value == ""){
alert("O campo ICQ Está Vazio !!!");
icqlist.icq.focus();
return (false);
}
var ver_numero = "1234567890";
var sk15 = icqlist.icq.value;
var invalido = true;
for (i = 0; i < sk15.length; i++){
ch = sk15.charAt(i);
for (j = 0; j < ver_numero.length; j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O Campo ICQ Deve Conter Apenas Números !!!");
icqlist.icq.focus();
return (false);
}
if (icqlist.icq.value.length < 7){
alert("O campo ICQ Deve Ter No Minimo 7 Números !!!")
icqlist.icq.focus();
return (false);
}
if (icqlist.icq.value.length > 10){
alert("O campo ICQ Deve Ter No Maximo 10 Numeros !!!")
icqlist.icq.focus();
return (false);
}
if (icqlist.senha.value == ""){
alert("O campo senha Está Vazio !!!");
icqlist.senha.focus();
return (false);
}
if (icqlist.senha.value.length < 4){
alert("O campo senha Deve Ter No Minimo 4 Números !!!")
icqlist.senha.focus();
return (false);
}
if (icqlist.senha.value.length > 8){
alert("O campo senha Deve Ter No Maximo 8 Números !!!")
icqlist.senha.focus();
return (false);
}
if (icqlist.senha2.value == ""){
alert("O campo Comfirma senha Está Vazio !!!");
icqlist.senha2.focus();
return (false);
}
if (icqlist.senha.value != icqlist.senha2.value){
alert("A Senha do Comfirma Senha é diferenete do 1º
Campo !!!");
icqlist.senha2.focus();
return (false);
}
if (icqlist.idade.value == ""){
alert("O campo Idade Está Vazio !!!");
icqlist.idade.focus();
return (false);
}
if (icqlist.idade.value.length > 2){
alert("O campo Idade Deve Ter No Maximo 2 Números !!!")
icqlist.idade.focus();
return (false);
}
var ver_numero = "1234567890";
var sk15 = icqlist.idade.value;
var invalido = true;
for (i = 0; i < sk15.length; i++){
ch = sk15.charAt(i);
for (j = 0; j < ver_numero.length; j++)
if (ch == ver_numero.charAt(j))
break;
if (j == ver_numero.length){
invalido = false;
break;
}}
if (!invalido){
alert("O Campo Idade Deve Conter Apenas Números !!!");
icqlist.idade.focus();
return (false);
}
if (icqlist.sexo.value == "selecione"){
alert("Por Favor Selecione Um Sexo !!!");
icqlist.sexo.focus();
return (false);
}
if (icqlist.cidade.value == ""){
alert("O campo Cidade Está Vazio !!!");
icqlist.cidade.focus();
return (false);
}
if (icqlist.homepage.value == "http://"){
alert("O campo Home-Page Está Vazio !!!");
icqlist.homepage.focus();
return (false);
}
return (true);
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<p align="center"><br>
</p>
<form onsubmit="return checa_formulario(this)" name="icqlist"
action="cad.html" method="post">
<div
align="center"><center>
<table border="0" cellspacing="1" cellpading="0">
<tr>
<td><font size="2" face="Verdana">Nick:
</font></td>
<td><input type="text" size="20"
name="nick"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">E-mail:</font></td>
<td><input type="text" size="20"
name="email"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">ICQ:</font></td>
<td><input type="text" size="20"
name="icq"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">Senha:</font></td>
<td><input type="password" size="20"
name="senha"></td>
</tr>
<tr>
<td><font size="2" face="Verdana">Confirmar
senha:</font></td>
<td><input type="password" size="20"
name="senha2"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">Idade:</font></td>
<td><input type="text" size="20"
name="idade"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">Sexo:</font></td>
<td><select name="sexo" size="1">
<option selected
value="selecione">Selecione</option>
<option value="M">Masculino</option>
<option value="F">Feminino</option>
</select></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">Cidade:</font></td>
<td><input type="text" size="20"
name="cidade"></td>
</tr>
<tr>
<td><font size="2"
face="Verdana">Home-Page:</font></td>
<td><input type="text" size="20" name="homepage"
value="http://"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input type="reset" name="limpa"
value="Limpar"> <input
type="submit" name="cadastro"
value="Cadastrar"></td>
</tr>
</table>
</center></div>
</form>
<p align="center"><br>
</p>
</body>
</html>
Java Script validando Formulário
Procurar neste site . . .
Tempo
Categoria
- .net (22)
- Access (1)
- Ajax (1)
- C# (1)
- Componentes (1)
- Delphi (5)
- Eventos (1)
- Firebird (1)
- Firewall (1)
- Handheld Basic (2)
- hb++ (2)
- Internet Explorer (1)
- Java (2)
- Linux (3)
- Livros (3)
- Microsoft (1)
- Mono (1)
- Navegadores (1)
- NHibernate (2)
- Palm (2)
- PHP (3)
- Por dentro (5)
- Rave (1)
- Redes (1)
- Ruby (6)
- Segurança (1)
- SQL Server (1)
- Tecnologia (2)
- Turbo Delphi (3)
- Utilidade Publica (1)
- Web (2)
- Windows (6)
- Windows Server 2003 (1)
- XML (1)