<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comentários sobre: Javascript &#8211; Campo texto permitindo somente digitação de números</title>
	<atom:link href="http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros</link>
	<description>Notícias e Dicas sobre Tecnologia, Educação, Desenvolvimento, Web e Baboseiras em geral</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:05:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Por: Tomás Vásquez</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-11987</link>
		<dc:creator>Tomás Vásquez</dc:creator>
		<pubDate>Tue, 25 May 2010 19:57:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-11987</guid>
		<description>Agradeço a dica Lucas, mas o que exatamente não funciona?

Abraços
Tomás</description>
		<content:encoded><![CDATA[<p>Agradeço a dica Lucas, mas o que exatamente não funciona?</p>
<p>Abraços<br />
Tomás</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Lucas</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-11985</link>
		<dc:creator>Lucas</dc:creator>
		<pubDate>Tue, 25 May 2010 19:31:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-11985</guid>
		<description>Simplesmente, não funciona!</description>
		<content:encoded><![CDATA[<p>Simplesmente, não funciona!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Tomás Vásquez</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-5564</link>
		<dc:creator>Tomás Vásquez</dc:creator>
		<pubDate>Mon, 06 Jul 2009 16:27:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-5564</guid>
		<description>Pedro,

Independente da solução colocada, hoje eu uso jquery para a tarefa. Recomendo. Talvez escreva sobre no blog em breve.

Abraços
Tomás</description>
		<content:encoded><![CDATA[<p>Pedro,</p>
<p>Independente da solução colocada, hoje eu uso jquery para a tarefa. Recomendo. Talvez escreva sobre no blog em breve.</p>
<p>Abraços<br />
Tomás</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Pedro Filho</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-5511</link>
		<dc:creator>Pedro Filho</dc:creator>
		<pubDate>Sun, 05 Jul 2009 01:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-5511</guid>
		<description>isso não é mais facil:

</description>
		<content:encoded><![CDATA[<p>isso não é mais facil:</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Tomás Vásquez</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-1947</link>
		<dc:creator>Tomás Vásquez</dc:creator>
		<pubDate>Sat, 07 Feb 2009 00:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-1947</guid>
		<description>Bruno,

Percebi os erros. A maioria acontece quando da combinação de teclas, principalmente do uso da tecla shift. Abaixo segue o código corrigido:

function ForceNumericInput(event, This, AllowDecimal, AllowMinus)
{
	if(arguments.length == 1)
	{
    	var s = This.value;
    	// if &quot;-&quot; exists then it better be the 1st character
    	var i = s.lastIndexOf(&quot;-&quot;);
    	if(i == -1)
        	return;
    	if(i != 0)
       		This.value = s.substring(0,i)+s.substring(i+1);
       	return;
    }

    switch(event.keyCode)
    {
        case 8:     // backspace
        case 9:     // tab
        case 37:    // left arrow
        case 39:    // right arrow
        case 46:    // delete
            event.returnValue = true;
            return;
    }
    if(event.keyCode == 189)     // minus sign
    {
    	if(AllowMinus == false)
    	{
            CancelEventExecution(event);
            return;
        }


        // wait until the element has been updated to see if the minus is in the right spot
        var s = &quot;ForceNumericInput(document.getElementById(&#039;&quot;+This.id+&quot;&#039;))&quot;;
        setTimeout(s, 250);
        return;
    }
    if(AllowDecimal &amp;&amp; event.keyCode == 188 &amp;&amp; !event.shiftKey)
    {
        if(This.value.indexOf(&quot;,&quot;) &gt;= 0)
        {
        	// don&#039;t allow more than one dot
            CancelEventExecution(event);
            return;
        }
        event.returnValue = true;
        return;
    }
    // allow character of between 0 and 9
    if (!event.shiftKey)
	{
		if(event.keyCode &gt;= 48 &amp;&amp; event.keyCode &lt;= 57)
	    {
	        event.returnValue = true;
	        return;
	    }
	}
    
    CancelEventExecution(event);
}

Valeu pelo toque. Se tiver mais sugestões, é só falar!

Abraços

Tomás</description>
		<content:encoded><![CDATA[<p>Bruno,</p>
<p>Percebi os erros. A maioria acontece quando da combinação de teclas, principalmente do uso da tecla shift. Abaixo segue o código corrigido:</p>
<p>function ForceNumericInput(event, This, AllowDecimal, AllowMinus)<br />
{<br />
	if(arguments.length == 1)<br />
	{<br />
    	var s = This.value;<br />
    	// if &#8220;-&#8221; exists then it better be the 1st character<br />
    	var i = s.lastIndexOf(&#8220;-&#8221;);<br />
    	if(i == -1)<br />
        	return;<br />
    	if(i != 0)<br />
       		This.value = s.substring(0,i)+s.substring(i+1);<br />
       	return;<br />
    }</p>
<p>    switch(event.keyCode)<br />
    {<br />
        case 8:     // backspace<br />
        case 9:     // tab<br />
        case 37:    // left arrow<br />
        case 39:    // right arrow<br />
        case 46:    // delete<br />
            event.returnValue = true;<br />
            return;<br />
    }<br />
    if(event.keyCode == 189)     // minus sign<br />
    {<br />
    	if(AllowMinus == false)<br />
    	{<br />
            CancelEventExecution(event);<br />
            return;<br />
        }</p>
<p>        // wait until the element has been updated to see if the minus is in the right spot<br />
        var s = &#8220;ForceNumericInput(document.getElementById(&#8216;&#8221;+This.id+&#8221;&#8216;))&#8221;;<br />
        setTimeout(s, 250);<br />
        return;<br />
    }<br />
    if(AllowDecimal &amp;&amp; event.keyCode == 188 &amp;&amp; !event.shiftKey)<br />
    {<br />
        if(This.value.indexOf(&#8220;,&#8221;) &gt;= 0)<br />
        {<br />
        	// don&#8217;t allow more than one dot<br />
            CancelEventExecution(event);<br />
            return;<br />
        }<br />
        event.returnValue = true;<br />
        return;<br />
    }<br />
    // allow character of between 0 and 9<br />
    if (!event.shiftKey)<br />
	{<br />
		if(event.keyCode &gt;= 48 &amp;&amp; event.keyCode &lt;= 57)<br />
	    {<br />
	        event.returnValue = true;<br />
	        return;<br />
	    }<br />
	}</p>
<p>    CancelEventExecution(event);<br />
}</p>
<p>Valeu pelo toque. Se tiver mais sugestões, é só falar!</p>
<p>Abraços</p>
<p>Tomás</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bruno rios</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-1944</link>
		<dc:creator>bruno rios</dc:creator>
		<pubDate>Fri, 06 Feb 2009 18:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-1944</guid>
		<description>porém está permitindo o uso de ` (crase) e &#039; &quot;aspas simples&quot;...

também permite o uso de SHIFT e ALT, permitindo digitar ~!@#%^&amp;*()_+&quot; e também ¡²¤€¼½¾‘’¥×´</description>
		<content:encoded><![CDATA[<p>porém está permitindo o uso de ` (crase) e &#8216; &#8220;aspas simples&#8221;&#8230;</p>
<p>também permite o uso de SHIFT e ALT, permitindo digitar ~!@#%^&amp;*()_+&#8221; e também ¡²¤€¼½¾‘’¥×´</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bruno rios</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-1943</link>
		<dc:creator>bruno rios</dc:creator>
		<pubDate>Fri, 06 Feb 2009 18:42:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-1943</guid>
		<description>ja descobri... adicionei isso:

&#124;&#124; event.keyCode &gt;= 96 &amp;&amp; event.keyCode &lt;= 105</description>
		<content:encoded><![CDATA[<p>ja descobri&#8230; adicionei isso:</p>
<p>|| event.keyCode &gt;= 96 &amp;&amp; event.keyCode &lt;= 105</p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: bruno rios</title>
		<link>http://www.tomasvasquez.com.br/blog/tecnologia/javascript-campo-texto-permitindo-somente-digitacao-de-numeros/comment-page-1#comment-1942</link>
		<dc:creator>bruno rios</dc:creator>
		<pubDate>Fri, 06 Feb 2009 18:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.tomasvasquez.com.br/blog/?p=577#comment-1942</guid>
		<description>como habilito o teclado numerico? so estao funcionando os numeros da parte superior do teclado... abraço!</description>
		<content:encoded><![CDATA[<p>como habilito o teclado numerico? so estao funcionando os numeros da parte superior do teclado&#8230; abraço!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

