<HTML>
<HEAD>
<script type="text/Javascript"> function checkDec(el)
{
var ex = /^[0-9]+\.?[0-9]*$/;
if(ex.test(el.value)==false)
{
el.value = el.value.substring(0,el.value.length - 1);
}
}
</script>
</HEAD>
<BODY>
<input type="text" id="" onkeyup="checkDec(this);" />
</BODY>
</HTML>using this code, you can prevent to enter the more than 2 digit after decimal in javascript.
