Ir para conteúdo
Fórum Script Brasil

Rodrigo FINO

Membros
  • Total de itens

    3
  • Registro em

  • Última visita

Sobre Rodrigo FINO

Rodrigo FINO's Achievements

0

Reputação

  1. Obrigado Jhonata , mais ainda persiste o erro no meu Script, fiz a mudança que você me aconselhou não sei o poruqe acorre isso é so eu inserir uma nova função como telefone ele da esse erro para de fincionar o Script inteiro <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p>&nbsp <script type='text/javascript'> function formValidator(){ // Make quick references to our fields var firstname = document.getElementById('firstname'); var addr = document.getElementById('addr'); var zip = document.getElementById('zip'); var state = document.getElementById('state'); var username = document.getElementById('username'); var email = document.getElementById('email'); var tel = document.getElemetById('tel'); // adicionado o telefone // Check each input in the order that it appears in the form! if(isAlphabet(firstname, "Por favor entre com somente letras para seu nome")){ if(isAlphanumeric(addr, " Endereço numeros e letras juntos EX:55Nome da Rua")){ if(isNumeric(zip, "Por favor entre com um CEP valido")){ if(madeSelection(regiao, "Escolha sua Região")){ if(lengthRestriction(Apelido, 6, 8)){ if(emailValidator(email, "Entre com email valido")){ if(isNumeric(tel, "Entre com seu telefone")){ // não posso repetir a expressão isNumeric ? return true; } } } } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z_]+$/; // a mudança que você me aconselhou if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("Por favor digite entre " +min+ " and " +max+ " characters"); elem.focus(); return false; } } function madeSelection(elem, helperMsg){ if(elem.value == "Please Choose"){ alert(helperMsg); elem.focus(); return false; }else{ return true; } } function emailValidator(elem, helperMsg){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isNumeric(elem, helperMsg){ // a função para telefone var numericExpression = /^[0-9]+$/; if(elem.value.match(isNumeric)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } </script> <form onsubmit='return formValidator()' > Nome: <input type='text' id='firstname' /><br /> Endereço: <input type='text' id='addr' /><br /> CEP: <input type='text' id='zip' /><br /> Telefone: <input type='text' id='tel' /><br /> Região: <select id='state'> <option>Por favor escolha</option> <option>Norte</option> <option>Sul</option> <option>Leste</option> <option>Oeste</option> <option>Centro</option> </select><br /> Username(6-8 characters): <input type='text' id='username' /><br /> Email: <input type='text' id='email' /><br /> <input type='submit' value='Check Form' /> </form> ;</p> <p>&nbsp;</p> </body> </html> POxa queria tanto usar esse Script para meu site, como envio de informaçoes para meu Email
  2. O Que tem de errado no meu Script <script type='text/javascript'> function formValidator(){ // Make quick references to our fields var firstname = document.getElementById('firstname'); var addr = document.getElementById('addr'); var zip = document.getElementById('zip'); var state = document.getElementById('state'); var username = document.getElementById('username'); var email = document.getElementById('email'); var tel = document.getElemetById('tel'); // Check each input in the order that it appears in the form! if(isAlphabet(firstname, "Por favor entre com somente letras para seu nome")){ if(isAlphanumeric(addr, " Endereço numeros e letras juntos EX:55Nome da Rua")){ if(isNumeric(zip, "Por favor entre com um CEP valido")){ if(madeSelection(state, "Escolha sua Região")){ if(lengthRestriction(Apelido, 6, 8)){ if(emailValidator(email, "Entre com email valido")){ if(isNumeric(telefone, "Entre com seu telefone")){ return true; } } } } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphabet(elem, helperMsg){ var alphaExp = /^[a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z-+]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("Por favor digite entre " +min+ " and " +max+ " characters"); elem.focus(); return false; } } function madeSelection(elem, helperMsg){ if(elem.value == "Please Choose"){ alert(helperMsg); elem.focus(); return false; }else{ return true; } } function emailValidator(elem, helperMsg){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(isNumeric)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } </script> <form onsubmit='return formValidator()' > Nome: <input type='text' id='firstname' /><br /> Endereço: <input type='text' id='addr' /><br /> CEP: <input type='text' id='zip' /><br /> Telefone: <input type='text' id='tel' /><br /> Região: <select id='state'> <option>Por favor escolha</option> <option>Norte</option> <option>Sul</option> <option>Leste</option> <option>Oeste</option> <option>Centro</option> </select><br /> Username(6-8 characters): <input type='text' id='username' /><br /> Email: <input type='text' id='email' /><br /> <input type='submit' value='Check Form' /> </form>
  3. function isAlphanumeric(elem, helperMsg){ Aqui var alphaExp = /^[0-9a-zA-Z]+$/; Aqui if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } Onde esta o texto em vermelho, gostaria de saber como posso acrecentar a opção para que possa ser digitado um espaço __ na caixa de texto Agradeço quem poder ajudar http://superdrivepc.org Assistência Técnica
×
×
  • Criar Novo...