Validação de e-mail no formulário, com bloqueio se estiver sem @ ou .
Estou com dificuldades para validar o campo de e-mail, eu achei um script de alerta apenas, gostaria de bloquear o formulario se a pessoa não digitar um e-mail corretamente para avançar.
segue o codigo da minha pagina de formulario para melhor interpretação
form.asp
<html>
<head>
<title>titulo</title>
<%
session("dados_ok") = "S"
%>
<style type="text/css">
<!--
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
td img {display: block;}.style1 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style2 { font-size: 24px;
color: #003366;
}
.style3 {font-size: 18px}
.style6 {font-size: 9px}
</style>
<style>
.form {font-size: 11px; font-family: Tahoma; color: #333333; background-color: #E3E3E3; border: #666666 1px double;}
.botao {font-size: 11px; font-family: Tahoma; color: #333333;}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #575757;
}.style7 {color: #FF0000}
</style>
<!--Fireworks CS6 Dreamweaver CS6 target. Created Tue Feb 10 16:51:48 GMT-0200 2015-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<center>
<table width="990" border="0" cellpadding="0" cellspacing="0" bordercolor="#575757" bgcolor="" style="display: inline-table;"><!-- fwtable fwsrc="Sem título" fwpage="Página 1" fwbase="teste.jpg" fwstyle="Dreamweaver" fwdocid = "1645750182" fwnested="0" -->
<tr>
<td><img src="Images/spacer.gif" width="187" height="1" alt="" /></td>
<td><img src="Images/spacer.gif" width="600" height="1" alt="" /></td>
<td><img src="Images/spacer.gif" width="203" height="1" alt="" /></td>
<td><img src="Images/spacer.gif" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img name="teste_r1_c1" src="Images/teste_r1_c1.jpg" width="990" height="77" id="teste_r1_c1" alt="" /></td>
<td><img src="Images/spacer.gif" width="1" height="77" alt="" /></td>
</tr>
<tr>
<td rowspan="2"><img name="teste_r2_c1" src="Images/teste_r2_c1.jpg" width="187" height="668" id="teste_r2_c1" alt="" /></td>
<td>
<table width="600" height="250" border="0" bgcolor="#FFFFFF">
<tr>
<td height="350" colspan="5" valign="top"><div align="justify">
<p class="style1"> </p>
<p align="center" class="style1 style2 style3">Crie o seu login, para ter ofertas exclusivas </p>
<p align="center" class="style1"><img src="IMAGENS/logo_peq.jpg" width="150" height="61" /></p>
</div><br />
</font></font></font><font size="2" face="Verdana"><font color="#003366"><a name="formulario" id="formulario"></a>
<script language="JavaScript" type="text/javascript">
<!--
function validar(theForm)
{
// Verifica se o campo E-mail está preenchido
if (theForm.email.value == "")
{
alert("Favor preencher o campo \"e-mail\".");
theForm.email.focus();
return (false);
}
// Verifica se o campo Comentário está preenchido
if (theForm.senha.value == "")
{
alert("Favor preencher o campo \"Senha\".");
theForm.senha.focus();
return (false);
}
}
//-->
</script>
<script language=javascript>
function confere(){
if (document.theForm.email.value.indexOf('@', 0) == -1 || document.theForm.email.value.indexOf('.', 0) == -1){ alert("E-mail invalido!");
return false;
}
}
</script>
<script type="text/javascript">
var backup = new Array
function check_alpha(val,name) {
var goodChars = "0123456789abcdefghijklmnopqrstuxywvz"
var errors = 0
var isOk = 1
for(var i=0;i<val.length;i++) {
isOk = 1
for(var j=0;j<goodChars.length;j++) {
if(goodChars.charAt(j) == val.charAt(i)) {
isOk = 0
}
}
if(isOk == 1) {
errors++
break;
}
}
if(errors > 0) {
if(backup[name]) {
document.getElementById(name).value = backup[name]
}
else {
document.getElementById(name).value = ""
}
}
else {
backup[name] = val
}
}
</script>
<font color="#003366"><a name="formulario" id="formulario"></a></font><font size="2" face="Verdana">
<style>
.form {font-size: 11px; font-family: Tahoma; color: #333333; background-color: #E3E3E3; border: #666666 1px double;}
.botao {font-size: 11px; font-family: Tahoma; color: #333333;}
</style>
</font></font></font><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input type="hidden" name="subject" value="Cadastro de usuario do Site - JCM VEICULOS" />
<input type="hidden" name="recipient" value="jcmveiculos@outlook.com" />
<input type="hidden" name="redirect" value="http://www.jcmveiculos.com.br/index_logado.asp" />
</font>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td width="30%" align="right"><div align="right"><span class="style7"><font face="Verdana" size="2">E-mail</font></span><font color="#FF0000">*</font><font face="Verdana" size="2" color="#003366">:</font></div></td>
<form action="enviar_mensagem.asp?sessao=<%=session("dados_ok")%>" name="theForm" method="post" align="center" onSubmit="return validar(theForm)">
<td width="70%" align="left"><font color="#003366" size="2" face="Verdana">
<input name="email" type="text" class="form" id="email" size="60" maxlength="60" onblur="confere()" onkeyup="this.value = this.value.toLowerCase();" />
<br />
</font><font face="Verdana"><span class="style6 style7">(Digite um e-mail válido)</span></font> </td>
</tr>
<tr>
<td width="30%" align="right"><div align="right"><font color="#003366" size="2" face="Verdana">Cadastre uma senha</font><font color="#FF0000">*</font><font color="#003366" size="2" face="Verdana">:</font></div></td>
<td width="70%" align="left"><font color="#003366" size="2" face="Verdana">
<input name="senha" type="password" class="form" id="senha" size="60" maxlength="60" onChange="check_alpha(this.value,this.id)" onKeyUp="check_alpha(this.value,this.id)">
<br />
</font><font color="#003366" face="Verdana"><span class="style6">(Digite uma senha com letras e números) </span></font></td>
</tr>
<tr>
<td width="30%" height="25"><font color="#003366" size="2" face="Verdana"> </font></td>
<td width="70%" align="left"><font color="#003366" size="2" face="Verdana">
<input name="submit" type="submit" class="botao" onmouseover="window.status='Certifique-se que as informações estão corretas, e aperte o botão para envia-las';return false" onmouseout="window.status=('Tecnologia, GR Eletronic's!')" value="Prosseguir" />
</font></td>
</tr>
</table></td>
</tr>
</table>
</td>
<td rowspan="2"><img name="teste_r2_c3" src="Images/teste_r2_c3.jpg" width="203" height="668" id="teste_r2_c3" alt="" /></td>
<td><img src="Images/spacer.gif" width="1" height="400" alt="" /></td>
</tr>
<tr>
<td><img name="teste_r3_c2" src="Images/teste_r3_c2.jpg" width="600" height="268" id="teste_r3_c2" alt="" /></td>
<td><img src="Images/spacer.gif" width="1" height="268" alt="" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>Discussão (12)
Carregando comentários...