..:: MX Studio Fóruns ::..: Auto-Count TextArea - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Auto-Count TextArea

#1 User is online   xanburzum 

  • Group: Administrador
  • Posts: 2383
  • Joined: 04-November 08

Posted 03 January 2009 - 08:57 PM

contador, Limita os caracteres dentro do TextArea,o nome do formulário elemento vai dentro da função, o que exigiria a criação de uma nova função para a área que todos os textos necessários para monitorar personagem conta. a função, passando o nome do formulário do elemento TextArea , o campo para exibir o contador, e o número máximo de caracteres permitido para que o texto área.

form:

CÓDIGO
<form name="myForm"
action="/teste/dynamictextareacounter.asp?ID=<%=siteID%>"
method="post">
<b>Uma Função de Contagem e Limite de TextArea</b><br>
<textarea name="message1" wrap="physical" cols="28" rows="5"
onKeyDown="textCounter(document.myForm.message1,document.myForm.remLen1,125)"
onKeyUp="textCounter(document.myForm.message1,document.myForm.remLen1,125)"></textarea>
<br>
<input readonly type="text" name="remLen1" size="3" maxlength="3" value="125">
caracteres restantes
<br>
<textarea name="message2" wrap="physical" cols="28" rows="5"
onKeyDown="textCounter(document.myForm.message2,document.myForm.remLen2,125)"
onKeyUp="textCounter(document.myForm.message2,document.myForm.remLen2,125)"></textarea>
<br>
<input readonly type="text" name="remLen2" size="3" maxlength="3" value="125">
caracteres restantes
<br>
<input type="Submit" name="Submit" value="Submit">
<br>
</form>


Aqui está a função java script:

CÓDIGO
<script LANGUAGE="JavaScript">
<! - Use a função para múltiplas textarea em uma página ->
<! - Limitar o número de caracteres por textarea ->
<! - inicio
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) !
field.value = field.value.substring(0, maxlimit);

else
cntfield.value = maxlimit - field.value.length;
}
//  fim-->
</script>









0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)