
egalauber
Membros-
Total de itens
11 -
Registro em
-
Última visita
Sobre egalauber

egalauber's Achievements
0
Reputação
-
(Resolvido) problema em formatar cnpj
pergunta respondeu ao egalauber de egalauber em Ajax, JavaScript, XML, DOM
Mudei o script. este funcionou: <script language="javascript"> // JavaScript Document //adiciona mascara de cnpj function MascaraCNPJ(cnpj){ if(mascaraInteiro(cnpj)==false){ event.returnValue = false; } return formataCampo(cnpj, '00.000.000/0000-00', event); } //adiciona mascara ao CPF function MascaraCPF(cpf){ if(mascaraInteiro(cpf)==false){ event.returnValue = false; } return formataCampo(cpf, '000.000.000-00', event); } //valida o CPF digitado function ValidarCPF(Objcpf){ var cpf = Objcpf.value; exp = /\.|\-/g cpf = cpf.toString().replace( exp, "" ); var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10)); var soma1=0, soma2=0; var vlr =11; for(i=0;i<9;i++){ soma1+=eval(cpf.charAt(i)*(vlr-1)); soma2+=eval(cpf.charAt(i)*vlr); vlr--; } soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11)); soma2=(((soma2+(2*soma1))*10)%11); var digitoGerado=(soma1*10)+soma2; if(digitoGerado!=digitoDigitado && cpf != ""){ alert('CPF Invalido!'); Objcpf.focus(); } } //valida numero inteiro com mascara function mascaraInteiro(){ if (event.keyCode < 48 || event.keyCode > 57){ event.returnValue = false; return false; } return true; } //valida o CNPJ digitado function ValidarCNPJ(ObjCnpj){ var cnpj = ObjCnpj.value; var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2); var dig1= new Number; var dig2= new Number; exp = /\.|\-|\//g cnpj = cnpj.toString().replace( exp, "" ); var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13))); for(i = 0; i<valida.length; i++){ dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0); dig2 += cnpj.charAt(i)*valida[i]; } dig1 = (((dig1%11)<2)? 0:(11-(dig1%11))); dig2 = (((dig2%11)<2)? 0:(11-(dig2%11))); if(((dig1*10)+dig2) != digito && cnpj != ""){ alert('CNPJ Invalido!'); ObjCnpj.focus(); } } //formata de forma generica os campos function formataCampo(campo, Mascara, evento) { var boleanoMascara; var Digitato = evento.keyCode; exp = /\-|\.|\/|\(|\)| /g campoSoNumeros = campo.value.toString().replace( exp, "" ); var posicaoCampo = 0; var NovoValorCampo=""; var TamanhoMascara = campoSoNumeros.length;; if (Digitato != 8) { // backspace for(i=0; i<= TamanhoMascara; i++) { boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".") || (Mascara.charAt(i) == "/")) boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(") || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) if (boleanoMascara) { NovoValorCampo += Mascara.charAt(i); TamanhoMascara++; }else { NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); posicaoCampo++; } } campo.value = NovoValorCampo; return true; }else { return true; } } function ValidaEmail() { var obj = eval("document.cadastrocliente.email"); var txt = obj.value; if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7))) { alert('Este email parece ser um email inválido. Por favor digite outro!'); obj.focus(); } } function Valida(){ var nome = document.cadastrocliente.nome.value; var telefone = document.cadastrocliente.telefone.value; var celular = document.cadastrocliente.celular.value; var cnpj = document.cadastrocliente.cnpj.value; var cpf = document.cadastrocliente.cpf.value; var email = document.cadastrocliente.email.value; if(nome != "" && telefone != "" && celular != "" && documento != "" && endereco != "" && bairro != "" && cidade != "" && pergunta != "x" && resposta != "" && email != "" && senha != "" && confirmaSenha != ""){ document.cadastrocliente.envia.disabled = false; return } } //função que restringe caracteres digitados. Números ou letras function valida_digitos(Ncampo) { //caracteres permitidos if(Ncampo=="nome") er=/[0-9]/; if(Ncampo=="telefone" || Ncampo=="celular") er=/[a-z]/; digito=document.getElementById(Ncampo).value; var tempor; for (var i=0;i<digito.length; i++) { tempor = digito.substring(i,i+1); //se digitos não igual aos caracteres informado na variavel digitos, então é deletado if (er.test(digito)) { document.getElementById(Ncampo).value=digito.substring(0,digito.length-1); return false; break; } } } function txtBoxFormat(objeto, sMask, evtKeyPress) { var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; if(document.all) { // Internet Explorer nTecla = evtKeyPress.keyCode; } else if(document.layers) { // Nestcape nTecla = evtKeyPress.which; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } } sValue = objeto.value; // Limpa todos os caracteres de formatação que // já estiverem no campo. sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( " ", "" ); sValue = sValue.toString().replace( " ", "" ); fldLen = sValue.length; mskLen = sMask.length; i = 0; nCount = 0; sCod = ""; mskLen = fldLen; while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; } i++; } objeto.value = sCod; if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } </script> <form action="cadastrando cliente.php" method="post" name="cadastrocliente"> Nome <input type="text" name="nome" onKeyPress="valida_digitos('nome')" onKeyUp="return Valida()" maxlength="50" size="50" /><br><br> Telefone <input type="text" name="telefone" onKeyDown="valida_digitos('telefone')" onKeyPress="return txtBoxFormat(this, '(99)9999-9999', event);" onKeyUp="return Valida()" maxlength="13" size="20" /><br><br> Celular <input type="text" name="celular" onKeyDown="valida_digitos('celular')" onKeyPress="return txtBoxFormat(this, '(99)9999-9999', event);" onKeyUp="return Valida()" maxlength="13" size="20" /><br><br> CNPJ <input type="text" name="cnpj" onKeyPress="MascaraCNPJ(cadastrocliente.cnpj);" onBlur="ValidarCNPJ(cadastrocliente.documento);" onKeyUp="return Valida()" maxlength="18" size="50" /><br><br> CPF <input type="text" name="documento" onKeyPress="MascaraCPF(cadastrocliente.documento);" onBlur="ValidarCPF(cadastrocliente.cpf);" onKeyUp="return Valida()" maxlength="14" size="50" /><br><br> Email <input type="text" name="email" onKeyUp="return Valida()" onBlur="ValidaEmail();" maxlength="30" size="50" /><br><br> </form> -
estou tentando fazer um formulário q vá formatando o q o usuário vai digitando. alguns campos funcionam beleza mas o cnpj não. é difícil de explicar o q acontece, copiem essa parte do código e testem aí rapidinho q vocês vão ver na hora!! reparei q este problema acontece quando tenho 3 objetos seguidos, (3 .) ou (3 -) ou (3 /), como no cnpj tem 3 pontos e só depois um ífem (99.999.999.9999-99) o script eu peguei aqui mesmo no site. ajudem aí galera!!! agradeço <script language="javascript"> function txtBoxFormat(objeto, sMask, evtKeyPress) { var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; if(document.all) { // Internet Explorer nTecla = evtKeyPress.keyCode; } else if(document.layers) { // Nestcape nTecla = evtKeyPress.which; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } } sValue = objeto.value; // Limpa todos os caracteres de formatação que // já estiverem no campo. sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( " ", "" ); sValue = sValue.toString().replace( " ", "" ); fldLen = sValue.length; mskLen = sMask.length; i = 0; nCount = 0; sCod = ""; mskLen = fldLen; while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; } i++; } objeto.value = sCod; if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } </script> <form action="cadastrando cliente.php" method="post" name="cadastrocliente"> <input type="text" name="telefone" onKeyPress="return txtBoxFormat(this, '(99)9999-9999', event);" maxlength="13" size="25" /> <br> <input type="text" name="celular" onKeyPress="return txtBoxFormat(this, '(99)9999-9999', event);" maxlength="13" size="25" /> <br> <input type="text" name="cpf" onKeyPress="return txtBoxFormat(this, '999.999.999-99', event);" maxlength="14" size="25" /> <br> <input type="text" name="cnpj" onKeyPress="return txtBoxFormat(this, '99.999.999.9999-99', event);" maxlength="18" size="25" /> <br> </form>
-
(Resolvido) Envio de formulário com JavaScript não funciona no Firefox
pergunta respondeu ao egalauber de egalauber em Ajax, JavaScript, XML, DOM
Obrigado pela ajuda cara... Consegui resolver aqui... foi só colocar um id no formulário e fazer assim: document.getElementById('nome do id').submit(); -
Formulário está pronto - Preciso da explicação
pergunta respondeu ao egalauber de egalauber em Ajax, JavaScript, XML, DOM
tá í o código inteiro: <script language=javascript> //MÁSCARA DE VALORES function txtBoxFormat(objeto, sMask, evtKeyPress) { var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; if(document.all) { // Internet Explorer nTecla = evtKeyPress.keyCode; } else if(document.layers) { // Nestcape nTecla = evtKeyPress.which; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } } sValue = objeto.value; // Limpa todos os caracteres de formatação que // já estiverem no campo. sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( " ", "" ); sValue = sValue.toString().replace( " ", "" ); fldLen = sValue.length; mskLen = sMask.length; i = 0; nCount = 0; sCod = ""; mskLen = fldLen; while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; } i++; } objeto.value = sCod; if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } </script> <table border="0"> <tr> <td>Data:</td> <td><input type="text" size="20" onkeypress="return txtBoxFormat(this, '99/99/9999', event);" maxlength="10"> XX/XX/XXXX</td> </tr> <tr> <td>RG:</td> <td><input type="text" size="20" onkeypress="return txtBoxFormat(this, '99.999.999-9', event);" maxlength="12"> XX.XXX.XXX-X</td> </tr> <tr> <td>Telefone:</td> <td><input type="text" size="20" onkeypress="return txtBoxFormat(this, '(99)9999-9999', event);" maxlength="13"> (XX)XXXX-XXXX</td> </tr> <tr> <td>Código:</td> <td><input type="text" size="20" onkeypress="return txtBoxFormat(this, '99-999', event);" maxlength="6"> XX-XXX</td> </tr> </table> mas eu precisava saber coisas do tipo: O q faz document.all e document.layers?? O q ele está fazendo em nTecla == 8?? essa parte eu não entendi nada: while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; } i++; } essa também não entendi (o q são estes valores 47 e 58?): if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } -
Formulário está pronto - Preciso da explicação
uma questão postou egalauber Ajax, JavaScript, XML, DOM
Peguei este script aquí mesmo no site porque preciso fazer algo bem parecido, só q não entendo nada de JavaScript. Será q alguém poderia me dar a explicação? Tentar me "ensinar" o q está acontecendo no script?! Agradeço de coração! <script language=javascript> //MÁSCARA DE VALORES function txtBoxFormat(objeto, sMask, evtKeyPress) { var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; if(document.all) { // Internet Explorer nTecla = evtKeyPress.keyCode; } else if(document.layers) { // Nestcape nTecla = evtKeyPress.which; } else { nTecla = evtKeyPress.which; if (nTecla == 8) { return true; } } sValue = objeto.value; // Limpa todos os caracteres de formatação que // já estiverem no campo. sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( "-", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( ".", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( "/", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( ":", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( "(", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( ")", "" ); sValue = sValue.toString().replace( " ", "" ); sValue = sValue.toString().replace( " ", "" ); fldLen = sValue.length; mskLen = sMask.length; i = 0; nCount = 0; sCod = ""; mskLen = fldLen; while (i <= mskLen) { bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":")) bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) if (bolMask) { sCod += sMask.charAt(i); mskLen++; } else { sCod += sValue.charAt(nCount); nCount++; } i++; } objeto.value = sCod; if (nTecla != 8) { // backspace if (sMask.charAt(i-1) == "9") { // apenas números... return ((nTecla > 47) && (nTecla < 58)); } else { // qualquer caracter... return true; } } else { return true; } } </script> -
Só quero q envia com todos os campos preenchidos.
uma questão postou egalauber Ajax, JavaScript, XML, DOM
Pessoal tenho um pequeno formulário apenas com campos "select" para fazer uma busca. Tenho um pequeno código em javascript para que o formulário não vá com algum campo sem preencher. O resultado é enviado para uma página PHP. Só que se eu uso "submit" ele mostra o alert dizendo q tem campos sem preencher e manda o formulário assim mesmo. Se eu uso "buton" ele não manda o formulário. O q q eu faço?? Quero q o formulário seja enviado apenas se todos os campos estiverem preenchidos!! <script language="javascript"> function Valida(){ var tipo = document.BuscaRapida.tipo_imovel.value; var finalidade = document.BuscaRapida.finalidade_imovel.value; var dormitorios = document.BuscaRapida.dormitorios.value; var preço = document.BuscaRapida.preço.value; if(tipo == "nada"){ alert("Escolha o Tipo de Imóvel"); valores.BuscaRapida.tipo_imovel.focus(); return (false); } if(finalidade == "nada"){ alert("Escolha a Finalidade do Imóvel"); valores.BuscaRapida.finalidade_imovel.focus(); return (false); } if(dormitorios == 0){ alert("Escolha a quantidade de Dormitórios"); valores.BuscaRapida.dormitorios.focus(); return (false); } if(preço == 0){ alert("Escolha o Preço do Imóvel"); valores.BuscaRapida.preço.focus(); return (false); } return (true); } </script> <form method="post" action="../busca rapida.php" name="BuscaRapida"> . . . restante do formulário . . . <input type="submit" value="Buscar" onclick="Valida()"> // acho q o problema é nesta linha... como q eu faço?? "submit" mesmo ou "button" ? -
haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! youuuurrooooooooooooooooooooo............................ hahahahahahahahahahahahahahahahahahahahahahahahaha.......................... A Alegria em pessoa!!!!!!!!!!!!!!!!!!!!!!!!!!! Consegui galera!!!!!!!!! O problema era nas configurações do IIS. Mas não me perguntem o que foi exatamente que eu não sei!!!! Fiquei fuçando até conseguir!!!!!!!!!!!!!!!!!!! UUFAA......... :D
-
Continuo fuçando aquí... Agora quando eu digito http://localhost/index.php fica carregando a página, demora bastante e depois aparece essa mensagem: CGI Timeout The specified CGI application exceeded the allowed time for processing. The server has deleted the process. e aí gente??? O que eu faço??
-
Estou tentando instalar o PHP no WinXP SP2 com o IIS. Baixei o php-5.2.5 e extraí para uma pasta "php" na unidade C: Fui nas propriedades do Meu Computador - na guia "Avançado" - no botão "variáveis de ambiente", nas "variáveis do sistema" fui na variável "Path" e inseri C:\php. Na pasta C:\php, copiei o arquivo php.ini-recommended (também tentei com o php.ini-dist) para a pasta Windows, renomiei para php.ini e editei da seguinte forma: doc_root = C:\Inetpub\wwwroot extension_dir = C:\php\ext cgi.force_redirect = 0 (nesta linha eu tirei o ";" e mudei o 1 pelo 0) Voltei no IIS fui com o botão direito na pasta "sites da web" na aba "filtro ISAPI" adicionei um filtro com nome PHP e o arquivo C:\php\php5isapi.dll No “Diretório Base” fui no campo “Permissões de execução” coloquei “Somente scripts”, fui “Configuração” fui na aba “Mapeamentos”, botão “Adicionar” no campo “Executável” coloquei C:\php\php5isapi.dll e no campo “Extensão” coloquei .php Na aba "Documentos" adicionei o documento index.php Reiniciei o IIS. Achei que estava pronto. Pra testar, criei um arquivo no bloco de notas com as instruções: <? phpinfo(); ?> e salvei com nome de index.php na pasta C:\Inetpub\wwwroot Fui no IE e digitei: http://localhost/index.php (também tentei com http://127.0.0.1/index.php) mas aparece o conteúdo do arquivo, ao invés de aparecer a página do PHP Galera me ajudem aí!!!! Hoje eu vou ficar por conta disso! To precisando muito terminar isso!!! Agradeço a todos!
-
Quero colocar uma página só de fotos no meu site. Quando a pessoa clicar em alguma foto, quero que abra uma nova janelinha com a foto, e nessa janelinha a pessoa muda de uma foto para a outra sem precisar voltar para a página de fotos. ### COMO EU FAÇO ISSO??? ### Também quero que a pessoa possa fazer downloads de algum material da minha página! ### TAMBÉM NÃO SEI FAZER ISSO!!! ### Estou começando a aprender a criar sites. Estou trabalhando com o Dreamweaver e não tenho muito conhecimento em HTML. Me mandem alguma dica, passo a passo, apostila, tutorial, vídeo . . . Qualquer coisa que me ajude nisso! valeu !!!!!