Dear Sir,
I have following codes
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Numeric Textbox</title>
<SCRIPT LANGUAGE="JAVASCRIPT">
//------------------------------------------------------------------
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57 || charCode == 110))
{
alert("Enter Numeric data Only");
return false;
}
else
{
return true;
}
}
//------------------------------------------------------------------
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
//------------------------------------------------------------------
</script>
</head>
<body onload="form1.text1.focus()">
<center>
<fieldset style=width:300px;background-color:#E0FFFF )>
<Legend style=color:blue;><b><font size=5>Numeric Input</font></b></legend>
<form name="form1">
<table cellpadding="1" cellspacing="3" border="0">
<tr>
<td>1st Number</td>
<td><input type="text" name="text1" onkeypress="return isNumberKey(event)";
onblur="form1.text1.value=formatCurrency(form1.text1.value)" >
</td>
</tr>
</table>
</form>
</fieldset>
</center>
</body>
</html>
The textbox accept only numeric values.
How to modify codes to accept . (decimal).
I want to enter data as
254228.25
Please help