Code:
<input onkeypress="return isNumberKey(event)" type="number" value="" />
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46){
return false;
}
return true;
}
The above function allows user to enter value with more than two decimal i.e. 10.5678
. How can I modify the function and restrict user to enter values upto two decimal i.e. 10.56