function valida(theForm){ if (theForm.Nome.value == "") { alert("Por favor, informe um valor para o campo \"Nome\"."); theForm.Nome.focus(); return (false); } if (theForm.Empresa.value == "") { alert("Por favor, informe um valor para o campo \"Empresa\"."); theForm.Empresa.focus(); return (false); } if (theForm.Endereco.value == "") { alert("Por favor, informe um valor para o campo \"Endereço\"."); theForm.Endereco.focus(); return (false); } if (theForm.Cidade.value == "") { alert("Por favor, informe um valor para o campo \"Cidade\"."); theForm.Cidade.focus(); return (false); } if (theForm.DDD_Fone.value == "") { alert("Por favor, informe um valor para o campo \"DDD do Telefone\"."); theForm.DDD_Fone.focus(); return (false); } if (theForm.Fone.value == "") { alert("Por favor, informe um valor para o campo \"Número do Telefone\"."); theForm.Fone.focus(); return (false); } if (theForm.Email.value == "") { alert("Por favor, informe um valor para o campo \"E-mail\"."); theForm.Email.focus(); return (false); } else { var x = Verifica_Email(theForm.Email); if (x == false) { return(false); } } return (true); } function Verifica_Email(field) { if (field.value != '') { var emailok = 0; var priaroba = field.value.indexOf('@'); var ultponto = field.value.lastIndexOf('.'); if (field.value.indexOf('@') > 0 ) { if (field.value.lastIndexOf('@') == field.value.indexOf('@')) { if (field.value.lastIndexOf('.') > 0 ) { if ( field.value.lastIndexOf('.') != field.value.length - 1) { if ( ultponto > priaroba ) { var emailok = 1; } } } } } if (emailok != 1) { alert('E-mail inválido.'); field.focus(); return (false); } } }