Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

pmap

dois return na mesma linha....

Recommended Posts

<td><input type='text' name='tel' onKeyPress='return handleEnter(this, event); return TelefoneFormat(this,event)'></td>q q tem de errado?pq n funfa?me ajudem. por favor.grato.Pedro Márcio

Compartilhar este post


Link para o post
Compartilhar em outros sites

bem nunca usei dois returns juntos, as funçoes funcionam individulmente???

Compartilhar este post


Link para o post
Compartilhar em outros sites

bem nunca usei dois returns juntos, as funçoes funcionam individulmente???

<{POST_SNAPBACK}>

Acho que uma função está invalidando a outra... Mas ele não voltou para postar o script... http://forum.imasters.com.br/public/style_emoticons/default/assobiando.gif

<{POST_SNAPBACK}>

bom dia.

 

eu esqueci de postar os codes.

 

<script type="text/javascript">function handleEnter (field, event) {var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;if (keyCode == 13) {var i;for (i = 0; i < field.form.elements.length; i++)if (field == field.form.elements[i])break;i = (i + 1) % field.form.elements.length;field.form.elements[i].focus();return false;}elsereturn true;}</script><script LANGUAGE="JavaScript"> function TelefoneFormat(Campo, e) {     var key = '';     var len = 0;     var strCheck = '0123456789';     var aux = '';     var whichCode = (window.Event) ? e.which : e.keyCode;          if (whichCode == 13 || whichCode == 8 || whichCode == 0)     {         return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico     }     key = String.fromCharCode(whichCode);     if (strCheck.indexOf(key) == -1){         return false;  //NÃO E VALIDO     }          aux =  Telefone_Remove_Format(Campo.value);          len = aux.length;     if(len>=10)     {         return false;    //impede de digitar um telefone maior que 10     }     aux += key;          Campo.value = Telefone_Mont_Format(aux);     return false; } function  Telefone_Mont_Format(Telefone) {     var aux = len = '';          len = Telefone.length;     if(len<=9)     {         tmp = 5;     }     else     {         tmp = 6;     }          aux = '';     for(i = 0; i < len; i++)     {         if(i==0)         {             aux = '(';         }         aux += Telefone.charAt(i);         if(i+1==2)         {             aux += ')';         }                  if(i+1==tmp)         {             aux += '-';         }     }     return aux; } function  Telefone_Remove_Format(Telefone) {     var strCheck = '0123456789';     var len = i = aux = '';     len = Telefone.length;     for(i = 0; i < len; i++)     {         if (strCheck.indexOf(Telefone.charAt(i))!=-1)         {             aux += Telefone.charAt(i);         }     }     return aux; } </script>
aí estão os dois codes.

 

um é pra usar o ENTER como TAB, e o outro é uma máscara para telefones.

 

agradeço desde já.

e me desculpem.

 

grato.

 

Pedro Márcio

Compartilhar este post


Link para o post
Compartilhar em outros sites

Hehehehe, pra quê complicar?

Eu estou usando esses no meu sistema:

 

===================Enter to Tab======================

Entre <head></head>

<script>function fcnFocusNext() { //Transforma enter em tab	if(event.keyCode==13) event.keyCode=9;}function fcnConfInputs() { //Insere função fcnFocusNext() em todos campos de texto  for (var i=0; i<document.forms[0].elements.length; i++) {    if (document.forms[0].elements[i].type == "text") {      document.forms[0].elements[i].onkeydown=function(){fcnFocusNext()};   }  }}function fcnOnlyNum() { //Só aceita digitar números	var caract = new RegExp(/^[0-9]+$/i);	var caract = caract.test(String.fromCharCode(event.keyCode));	if(!caract){  event.keyCode=0;  return;	}}function mask(campo) { //Mascarador	len = document.getElementById(campo).value.length;	cmp = document.getElementById(campo);	if (campo == 'cep') {  if (len == 2) { cmp.value = cmp.value + '.'; return; }  if (len == 6) { cmp.value = cmp.value + '-'; return; }  if (cmp.value.charAt(2) != '.') { keyCode = 0 };  if (cmp.value.charAt(6) != '-') { keyCode = 0 };	}	if (campo == 'cpf') {  if (len == 3) { cmp.value = cmp.value + '.'; return; }  if (len == 7) { cmp.value = cmp.value + '.'; return; }  if (len == 11) { cmp.value = cmp.value + '-'; return; }  if (cmp.value.charAt(3) != '.') { keyCode = 0 };  if (cmp.value.charAt(7) != '.') { keyCode = 0 };  if (cmp.value.charAt(11) != '-') { keyCode = 0 };	}	if (campo == 'cnpj') {  if (len == 3) { cmp.value = cmp.value + '.'; return; }  if (len == 7) { cmp.value = cmp.value + '.'; return; }  if (len == 11) { cmp.value = cmp.value + '/'; return; }  if (len == 16) { cmp.value = cmp.value + '-'; return; }  if (cmp.value.charAt(3) != '.') { keyCode = 0 };  if (cmp.value.charAt(7) != '.') { keyCode = 0 };  if (cmp.value.charAt(11) != '/') { keyCode = 0 };  if (cmp.value.charAt(16) != '-') { keyCode = 0 }	}		if ( (campo == 'tel') || (campo == 'telefone') || (campo == 'cel') || (campo == 'celular') || (campo == 'fax') ) {  if (len == 2) { cmp.value = cmp.value + ' '; return; }  if (len == 7) { cmp.value = cmp.value + '-'; return; }  if (cmp.value.charAt(2) != ' ') { keyCode = 0 };  if (cmp.value.charAt(7) != '-') { keyCode = 0 }	}}</script>

No final da página:

   <script>    fcnConfInputs();    </script>

Na tag

<input name="telefone" type="text" id="telefone" size="20"  maxlength="12" onKeyPress="fcnOnlyNum();mask(this.name);">

 

 

Tudo testado e funcionando

 

Abraços, T+ http://forum.imasters.com.br/public/style_emoticons/default/bye1.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.