
Validar Numeros Decimais
#1
Posted 18/01/2007, 13:54
Segue abaixo os Scripts que tenho:
<script>
function SoNumeros() // Função para Números Inteiros
{
var carCode = event.keyCode;
if ((carCode < 48) || (carCode > 57))
{
alert ("Por favor, digite apenas números!");
//alert(teclapres);
event.cancelBubble = true;
event.returnValue = false;
return false;
}
}
function ValidNum(e,n){
if (document.all) // Internet Explorer
var tecla = event.keyCode;
else if(document.layers) // Nestcape
var tecla = e.which;
if ((tecla ==46) || (tecla == 44) || (tecla > 46 && tecla < 58 )) // numeros de 0 a 9 , e . e /
return true;
else{
if ((tecla == 13)||(tecla==9)){
n.focus();
return false;}
if (tecla != 8) // backspace
{event.keyCode = 0;
alert ("Por favor, digite somente números!");
return false;
}else
return true;
}
}
</SCRIPT>
<body>
<form class="boxLeft" id="frmDecimal" action="#" >
<div>
<label for="txtDecimal">Decimal:</label>
<input type="text" size="10" id="txtDecimal" name="txtDecimal" onkeypress="ValidNum(event,this.value)" />
<input type="text" size="10" id="txtDecimal" name="txtDecimal" onkeypress="SoNumeros()" />
</div>
</form>
- HaroNism likes this
#2
Posted 18/01/2007, 14:05
#3
Posted 18/01/2007, 14:19

#4
Posted 18/01/2007, 18:40

http://forum.imaster...howtopic=211325
Então fiz assim:
function isNumber (text){
valor = parseFloat(text);
if ((!isNaN(valor))==false){alert("Por favor, não digite ...");}
return true;
}
Mas mesmo digitando numeros ele dah o alert
Será que não assimilei a lógica...
A lógica está certa pois eu testei aqui e funcionou ... posta os exemplos que você testou e não responderam como o esperado.
Edição feita por: matt.cavotta, 18/01/2007, 18:47.
I'm back!

#5
Posted 19/01/2007, 09:06
Tinha razão, estava chamando indeviadamente a função, por isso não funcionava...rs

Muito obrigada (2X

#6
Posted 21/09/2017, 23:53
Tetracylin Kaufen Amoxicillin Effect On Birth Control Phu Buy Viagra Usa Html Buy Viagra Usa
Cialis Tablets 10mg <a href=http://cialtobuy.com>cialis</a> Best Viagra Online Reviews
#7
Posted 13/10/2017, 19:12
#8
Posted 14/10/2017, 00:38
#9
Posted 31/10/2017, 07:27
Order Doxycycline Hyclate Viagra Se Vende Con Receta Medica viagra Viagra Plus Priligy
#10
Posted 22/11/2017, 15:43
Comment Durer Longtemps buy viagra online Acyclovir Price Buspar Discontinued
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)