Ir para conteúdo

POWERED BY:

Arquivado

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

fael

Digitar ao contrário

Recommended Posts

Pessoal, Alguém aí sabe como eu faço para trocar o início da digitação de um campo,ou seja, começar da direita para a esquerda? :D Att.,

Compartilhar este post


Link para o post
Compartilhar em outros sites

Depois de muito procurar pela web, enfim encontrei!!! :D http://forum.imasters.com.br/public/style_emoticons/default/joia.gif

 

Taí o código:

 

<html><head><title>[- Campo com valor moeda -]</title><script language="JavaScript">function currencyFormat(fld, milSep, decSep, e) { var sep = 0; var key = ''; var i = j = 0; var len = len2 = 0; var strCheck = '0123456789'; var aux = aux2 = ''; var whichCode = (window.Event) ? e.which : e.keyCode; if (whichCode == 13) return true;  // Entra key = String.fromCharCode(whichCode);  // Comece o valor chave do c?digo chave if (strCheck.indexOf(key) == -1) return false;  // Chave inv?lida len = fld.value.length; for(i = 0; i < len; i++) if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; aux = ''; for(; i < len; i++) if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i); aux += key; len = aux.length; if (len == 0) fld.value = ''; if (len == 1) fld.value = '0'+ decSep + '0' + aux; if (len == 2) fld.value = '0'+ decSep + aux; if (len > 2) {  aux2 = '';  for (j = 0, i = len - 3; i >= 0; i--) {   if (j == 3) {    aux2 += milSep;    j = 0;   }   aux2 += aux.charAt(i);   j++;  }  fld.value = '';  len2 = aux2.length;  for (i = len2 - 1; i >= 0; i--)  fld.value += aux2.charAt(i);  fld.value += decSep + aux.substr(len - 2, len); } return false;}</script></head><body><form><i>Entre com um valor:</i><br><input type=text name=test maxlength="10" onKeyPress="return(currencyFormat(this,'.',',',event))" style="text-align:right"></form></body><html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal, Vou continuar pedindo a ajuda de vcs!!! :D Na verdade o código acima é meio complicado, não entendi muito bem, gostaria de saber onde eu controlo a quantidade de números após a vírgula.

Compartilhar este post


Link para o post
Compartilhar em outros sites

cara, fiz uma roitna menor, pois acho que seu problema é criar uma máscara para os dados, veja ai, ok!.script type="text/javascript">function mascara(item){ if (document.Testform.valor.value.length==2){ document.Testform.valor.value+="."; } if (document.Testform.valor.value.length==6){ document.Testform.valor.value+=","; }return true;}</script><form name="Testform" action=""><input name="valor" type="text" value="" size="9" maxlength="9" style="text-align:right"' onkeydown="mascara()"></form>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Cara, seguinte, o meu problema não é esse, não é isso que eu quero, copia o meu código e testa pra ver do que eu estou falando.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consegui resolver o meu problema:Eu configura na linha onde diz:fld.value += decSep + aux.substr(len - 2, len);O número 2 é a chave do esquema. :D

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.