<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Programação em ASP &#187; limite textarea</title>
	<atom:link href="http://quantodaniel.wordpress.com/tag/limite-textarea/feed/" rel="self" type="application/rss+xml" />
	<link>http://quantodaniel.wordpress.com</link>
	<description>Estudando como programar!</description>
	<lastBuildDate>Sun, 02 Aug 2009 06:37:57 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='quantodaniel.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/bfc920e28461661a78837d8e9ef12218?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Programação em ASP &#187; limite textarea</title>
		<link>http://quantodaniel.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://quantodaniel.wordpress.com/osd.xml" title="Programação em ASP" />
		<item>
		<title>Contador de caracteres em ASP.</title>
		<link>http://quantodaniel.wordpress.com/2007/11/14/contador-de-caracteres-em-asp/</link>
		<comments>http://quantodaniel.wordpress.com/2007/11/14/contador-de-caracteres-em-asp/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 14:10:30 +0000</pubDate>
		<dc:creator>quantodaniel</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[contador em asp]]></category>
		<category><![CDATA[limite textarea]]></category>

		<guid isPermaLink="false">http://quantodaniel.wordpress.com/2007/11/14/contador-de-caracteres-em-asp/</guid>
		<description><![CDATA[Bom dia, nesse post vou mostrar como fazer um contador e limitar o usuário a digitar x números de caracteres em um campo de texto.
Utilizaremos JavaScript para a validação do campo.

Primeiro criamos o campo de mensagem e o campo do contador:

&#60;label&#62;Mensagem:&#60;br&#62;
&#60;textarea onKeyUp="javascript:contador();" name="mensagem" cols="30" rows="10"&#62;&#60;/textarea&#62;
&#60;/label&#62;
&#60;p&#62;Máximo 20 caracteres.&#60;/p&#62;
&#60;p&#62;Contador:    &#60;label&#62;
&#60;input name="contador" type="text" value="0" size="6" [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quantodaniel.wordpress.com&blog=2059213&post=9&subd=quantodaniel&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bom dia, nesse post vou mostrar como fazer um contador e limitar o usuário a digitar x números de caracteres em um campo de texto.</p>
<p>Utilizaremos JavaScript para a validação do campo.</p>
<ol>
<li>Primeiro criamos o campo de mensagem e o campo do contador:</li>
<li>
<pre>&lt;label&gt;Mensagem:&lt;br&gt;
&lt;textarea onKeyUp="javascript:contador();" name="mensagem" cols="30" rows="10"&gt;&lt;/textarea&gt;
&lt;/label&gt;
&lt;p&gt;Máximo 20 caracteres.&lt;/p&gt;
&lt;p&gt;Contador:    &lt;label&gt;
&lt;input name="contador" type="text" value="0" size="6" &gt;
&lt;/label&gt; &lt;/p&gt;</pre>
</li>
<li>Aqui foi criado um campo de texto onde cada tecla pressionada pelo usuário chama uma função chamada &#8220;contador&#8221;.</li>
<li>O campo &#8220;contador&#8221; recebe o tamanho do campo &#8220;mensagem&#8221;.</li>
<li>Aqui temos a função em JavaScript:</li>
<li>
<pre>&lt;script&gt;
function contador(){
var vlr_msg = document.getElementById("mensagem");
var vlr_cont = document.getElementById("contador");
vlr_cont.value = vlr_msg.value.length;
var limite = 20; if (vlr_msg.value.length &gt;= limite) {
vlr_msg.value = vlr_msg.value.substring(0, limite-1);
}
}
&lt;/script&gt;</pre>
</li>
<li></li>
<li>Nãoé tão complicada, na linha 2 e 3, definimos as variaveis, na linha 4 defino que o valor (&#8220;value&#8221;) do contador recebe o tamanho (&#8220;value.length&#8221;) do campo mensagem.</li>
<li>Na linha 5 definimos um limite para o campo mensagem.</li>
<li>Na linha 6 verificamos se a quantidade de caracteres digitadas é maior ou igual ao limite pré-definido.</li>
<li>Se a condição for verdadeira, a função não deixa que o texto seja maior que o limite (&#8220;substring(0, limite-1)&#8221;).</li>
</ol>
<p>Veja o exemplo <a href="http://www.linkoff.com.br/contador.asp" title="Exemplo" target="_blank">AQUI</a>.</p>
<p>Até mais.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/quantodaniel.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/quantodaniel.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/quantodaniel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/quantodaniel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/quantodaniel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/quantodaniel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/quantodaniel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/quantodaniel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/quantodaniel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/quantodaniel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/quantodaniel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/quantodaniel.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=quantodaniel.wordpress.com&blog=2059213&post=9&subd=quantodaniel&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://quantodaniel.wordpress.com/2007/11/14/contador-de-caracteres-em-asp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6e1a13a71cc89521c4b6e83f914cbac1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">quantodaniel</media:title>
		</media:content>
	</item>
	</channel>
</rss>