Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda Com Um Codigo Meio Longo...


Guest Colegial sex

Pergunta

Guest Colegial sex

Pessoal, tenho um codigo feito por um amigo mais fiu apkica-lo no meu form e deu aguns problemas... meu amigo só disse que seria facil de entender o codigo, ate ai beleza... eu entendi... porem não consegui aplica-lo no meu form porque já tenho outro codigo no meu form...

se alguém poder ajudar a aplkica-lo no meu form e corrigir os erros do cosigo java script...

segue abaixo o codigo JavaScript do arquivo funcoes.js:

botao_clicado = false;
function valida(){
  if (!botao_clicado){
  	botao_clicado = true;
  	if (valida_dados()) {
    return true;
  	}else { return false; }
  	}else{
  alert("Aguarde... Processo em andamento.");
	}
}

function verifica_mail(mail) {
var iCount, vPos, Achou, dom, formulario;

	if (mail.length == 0) return true;

	formulario = document.assinatura
	achou = false;

    for (iCount = 1; iCount<mail.length; iCount++){ // comeca na segunda posicao da string
        if (mail.charAt(iCount) == '@') {
  	achou = true;
            vPos = iCount;
            break;
        }
    }
	if (achou == false) {
  alert('E-mail incorreto.');
  formulario.email.focus();
  return false;
	}
return true;
}

function valida_dados() {
var Form, resposta, s, cnpj, cpf, cep;
	Form = document.assinatura;

	if (Form.dominio.value.length == 0) {
  alert('O campo de Domínio é obrigatório!');
  Form.dominio.focus();
  botao_clicado=false
  return false;
	}
	if (Form.nome.value.length == 0) {
  alert('O campo de Nome ou Razão Social é obrigatório !');
  Form.razao.focus();
  botao_clicado=false
  return false;
    }
	// checa se é cpf
	if (Form.cpf.value.length == 0 || Form.cpf.value.length <=10) {
  alert('O CPF/CNPJ não é válido !');
  Form.cpf.focus();
  botao_clicado=false
  return false;
	}
	else if (Form.cpf.value.length == 11) {
	// é CPF
  if (valida_CPF(Form.cpf.value) == false ) {
  	alert('O CPF não é válido !');
  	Form.cpf.focus();
  	botao_clicado=false
  	return false;
  }
	}
	// é cnpj
	else if (valida_cnpj(Form.cpf.value) == false ) {
  alert('O CNPJ não é válido !');
  Form.cpf.focus();
  botao_clicado=false
  return false;
	}
	if (Form.endereco.value.length == 0) {
  alert('O Endereço é um campo obrigatório !');
  Form.endereco.focus();
  botao_clicado=false
  return false;
	}
	if (Form.cidade.value.length == 0) {
  alert('A Cidade é um campo obrigatório !');
  Form.cidade.focus();
  botao_clicado=false
  return false;
	}
	if (Form.estado.options[0].selected == true) {
  alert('O Estado é um campo obrigatório !');
  Form.estado.focus();
  botao_clicado=false
  return false;
	}
	if (Form.cep.value.length < 5) {
  alert('O CEP é um campo obrigatório !');
  Form.cep.focus();
  botao_clicado=false
  return false;
  }
	if (Form.ddd.value.length == 0) {
  alert('O DDD é obrigatório !');
  Form.ddd.focus();
  botao_clicado=false
  return false;
	}
	if (Form.telcom.value.length == 0) {
  alert('O Telefone Residêncial é obrigatório !');
  Form.telcom.focus();
  botao_clicado=false
  return false;
	}
	if (Form.email1.value.length == 0) {
  alert('O E-mail é um campo obrigatório !');
  Form.email1.focus();
  botao_clicado=false
  return false;
	}
	if (Form.plano.options[0].selected == true) {
  alert('O Plano é um campo obrigatório !');
  Form.plano.focus();
  botao_clicado=false
  return false;
	}
//	if (Form.dia.options[0].selected == true) {
//  alert('O dia de vencimento é um campo obrigatório !');
//  Form.dia.focus();
//  botao_clicado=false
//  return false;
//	}
        if (Form.senha.value.length == 0) {
  alert('A Senha é um campo obrigatório !');
  Form.senha.focus();
  botao_clicado=false
  return false;
    }
	if (Form.Forma_de_Pagto.options[0].selected == true) {
  alert('A Forma de Pagamento é um campo obrigatório !');
  Form.Forma_de_Pagto.focus();
  botao_clicado=false
  return false;
	}
	return true;
}

function valida_CPF(s){
var i;
var c = s.substr(0,9);
var dv = s.substr(9,2);
var d1 = 0;
	for (i = 0; i < 9; i++){
  d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
  return false;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++){
  d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
  return false;
	}
	return true;
}

function valida_cnpj(s){
var i;
var c = s.substr(0,12);
var dv = s.substr(12,2);
var d1 = 0;
	for (i = 0; i < 12; i++){
  d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
  return false;
	}
	d1 *= 2;
	for (i = 0; i < 12; i++){
  d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
  return false;
	}
	return true;
}

function valida_numero(s){
	if ( s != '' ) {
  var i;
  var dif = 0;
  for (i = 0; i < s.value.length; i++){
  	var c = s.value.charAt(i);
  	if (!((c >= '0') && (c <= '9'))){
    dif = 1;
  	}
  }
  if (dif == 1){
  	alert('Este campo deve ser numerico!');
  	s.focus();
  	s.select();
  	return false;
  }
	}
	return true;
}
e abaixo o codigo do formulario que preciso validar... :
<html>
<head>
<title>Estou aqui!</title>
<meta http-equiv="Content-Type" content="text/html;">
<STYLE>
      .cellbox { border: 1px solid #888888; padding: 5px 5px 5px 5px; }
      .box-header { padding: 5px 5px 5px 5px; }
      .frm { background-color: #F0F0F0; border: 1px solid #888888; font-family: Verdana; font-size: 8pt; font-weight: bold; }
      .frm-on { background-color: rgb(177,200,150); border: 1px solid rgb(70,90,128); color: rgb(70,90,128); font-family: Verdana; font-size: 8pt; font-weight: bold; }
      .text-header { font-family: Verdana; font-size: 8pt; font-weight: bold; }
      .header { font-family: Verdana; font-size: 16pt; font-weight: bold; color: rgb(0,128,255); }
    </STYLE>


<script language="JavaScript">
<!--
function SymError()
{
  return true;
}
window.onerror = SymError;
//-->
    </script>

<script language="JavaScript" type="text/JavaScript">
<!--

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
//-->
</script>

</head>
<body bgcolor="#ffffff" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<center onmousemove="MM_displayStatusMsg('..:: MVhost &amp; Design - Alta Tecnologia Digital ::..');return document.MM_returnValue">
  <table width="94%" height="464" border="0">
    <tr> 
      <td align="center" valign="middle"> <center>
        </center>
        <p>&nbsp;</p>
        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="383" height="280" id="AutoNumber1">
          <tr> 
            <td width="383" height="278" align="justify"> <form method="POST" action="cadastro.php" name="form" style="word-spacing: 0; margin: 0">
                <div align="center"> 
                  <center>
                    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="383" height="375" id="AutoNumber1">
                      <tr> 
                        <td height="17"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Dom&iacute;nio:</b></font></td>
                        <td height="17"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            &nbsp; 
                            <input name="dominio" type="text" class="frm" id="dominio2" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="50">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="20"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b> 
                            Nome/Raz&atilde;o Social:</b></font></td>
                        <td width="202" height="20"> <p align="left" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"> 
                            <input type="text" name="nome" size="25" maxlength="60" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </span></td>
                      </tr>
                      <tr> 
                        <td width="181" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Endereço:</b></font></td>
                        <td width="202" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"> 
                            <input type="text" name="endereco" size="25" maxlength="100" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </span></td>
                      </tr>
                      <tr> 
                        <td width="181" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>CEP:</b></font></td>
                        <td width="202" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"> 
                            <input type="text" name="cepini" size="5" maxlength="5" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </span><font face="Verdana" size="1"> - </font> <span class="box-header"> 
                            <input type="text" name="cepfim" size="3" maxlength="3" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </span></td>
                      </tr>
                      <tr> 
                        <td width="181" height="19"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Bairro:</b></font></td>
                        <td width="202" height="19"> <p align="left" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"> 
                            <input type="text" name="bairro" size="25" maxlength="60" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </span></td>
                      </tr>
                      <tr> 
                        <td width="181" height="27"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Estado:</b></font></td>
                        <td width="202" height="27"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            &nbsp; 
                            <select name="estado" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                              <option selected>Selecione o estado</option>
                              <option value="Acre">Acre</option>
                              <option value="Alagoas">Alagoas</option>
                              <option value="Amapá">Amapá</option>
                              <option value="Amazonas">Amazonas</option>
                              <option value="Bahia">Bahia</option>
                              <option value="Ceará">Ceará</option>
                              <option value="Distrito Federal">Distrito Federal</option>
                              <option value="Espírito Santo">Espírito Santo</option>
                              <option value="Goiás">Goiás</option>
                              <option value="Maranhão">Maranhão</option>
                              <option value="Mato Grosso">Mato Grosso</option>
                              <option value="Mato Grosso do Sul">Mato Grosso do 
                              Sul</option>
                              <option value="Minas Gerais">Minas Gerais</option>
                              <option value="Pará">Pará</option>
                              <option value="Paraíba">Paraíba</option>
                              <option value="Paraná">Paraná</option>
                              <option value="Pernambuco">Pernambuco</option>
                              <option value="Piauí">Piauí</option>
                              <option value="Rio de Janeiro">Rio de Janeiro</option>
                              <option value="Rio Grande do Norte">Rio Grande do 
                              Norte</option>
                              <option value="Rio Grande do Sul">Rio Grande do 
                              Sul</option>
                              <option value="Rondônia">Rondônia</option>
                              <option value="Roraima">Roraima</option>
                              <option value="Santa Catarina">Santa Catarina</option>
                              <option value="São Paulo">São Paulo</option>
                              <option value="Sergipe">Sergipe</option>
                              <option value="Tocantins">Tocantins</option>
                            </select>
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="21"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Cidade:</b></font></td>
                        <td width="202" height="21"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            &nbsp; 
                            <input name="cidade" type="text"  class="frm" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="25">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="10"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Telefone 
                            Residencial:</b></font></td>
                        <td width="202" height="10"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">(0 
                            <input type="text" name="ddd" size="2" maxlength="2" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            ) - 
                            <input name="telresid" type="text" class="frm" id="telresid2" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="9" maxlength="10">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Telefone 
                            Comercial:</b></font></td>
                        <td width="202" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">(0 
                            <input type="text" name="aaaa" size="2" maxlength="2" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            ) - 
                            <input type="text" name="telcom" size="9" maxlength="10" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>RG:</b></font></td>
                        <td width="202" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input type="text" name="rg" size="25" class="frm" onBlur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';" maxlength="15">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="5"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>CPF 
                            / CNPJ:</b></font></td>
                        <td width="202" height="5"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input type="text" name="cpf" size="25"  class="frm" onblur="this.className='frm'; displayText('&nbsp;');" onFocus="this.className='frm-on';" maxlength="20">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>E-mail 
                            1:</b></font></td>
                        <td width="202" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input name="email1" type="text" class="frm" id="email1" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="40">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>E-mail 
                            2:</b></font></td>
                        <td width="202" height="11"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input name="email2" type="text" class="frm" id="email2" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="30">
                            </font></td>
                      </tr>
                      <tr> 
                        <td height="19"><font color="#006600" size="1" face="Verdana"><b>Forma 
                          de Pagamento:</b></font></td>
                        <td height="19"><font face="Verdana" size="1"> 
                          <select name="formadepgo"  class="frm" id="formadepgo" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');">
                            <option selected>Dep&oacute;sito Banc&aacute;rio</option>
                          </select>
                          </font></td>
                      </tr>
                      <tr> 
                        <td height="20"><font color="#006600" size="1" face="Verdana"><b>Plano:</b></font></td>
                        <td height="20"><font face="Verdana" size="1"> 
                          <select name="plano"  class="frm" id="plano" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');">
                            <option selected>MV Baby</option>
                            <option>MV Junior</option>
                            <option>MV Senior</option>
                            <option>MV-Commerce</option>
                          </select>
                          </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="17"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Username:</b></font></td>
                        <td width="202" height="17"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input name="user" type="text" class="frm" id="dominio2" onFocus="this.className='frm-on';" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="15">
                            </font></td>
                      </tr>
                      <tr> 
                        <td height="8"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font color="#006600" size="1" face="Verdana"><b>Senha:</b></font></td>
                        <td height="8"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1"> 
                            <input name="senha" type="password" class="frm" id="senha2" onFocus="this.className='frm-on'; displayText('&nbsp;Digite uma senha com no mínimo de 6 caracteres');" onBlur="this.className='frm'; displayText('&nbsp;');" size="25" maxlength="10">
                            </font></td>
                      </tr>
                      <tr> 
                        <td width="181" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">&nbsp;</font></td>
                        <td width="202" height="1"> <p align="left" style="margin-top: 0; margin-bottom: 0"><font face="Verdana" size="1">&nbsp;</font></td>
                      </tr>
                      <tr> 
                        <td height="1" colspan="2"> <p align="center" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"> 
                            <input name="submit" type="submit" class="frm" onMouseOver="this.className='frm-on';" onMouseOut="this.className='frm';" value="Cadastrar">
                            </span><font face="Verdana"> </font> <span class="box-header"> 
                            <input name="reset" type="reset" class="frm" onMouseOver="this.className='frm-on';" onMouseOut="this.className='frm';" value="Recomeçar">
                            </span> 
                          <p align="left" style="margin-top: 0; margin-bottom: 0"> 
                            <span class="box-header"><font face="Verdana" style="font-size: 3pt">&nbsp;</font></span> 
                        </td>
                      </tr>
                    </table>
                  </center>
                </div>
              </form></td>
          </tr>
        </table>
        <div align="center"></div></td>
    </tr>
  </table>
</center>
</body>
</html>

se alguém conseguir eu agradeço muito...

Obrigado a todos..

Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,8k
×
×
  • Criar Novo...