Only three or n decimal places are allowed

Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 1340
function checkDecimal(ID)
var strString = document.getElementById(ID).value;
var currIndex=strString.indexOf('.');
if(currIndex+4 <strString.length) // 4=n+1 number exmaple here is 3 code is for 3 decimal points so i used check for 4
alert("Only 3 decimal places are allowed to enter.");
return false;

Comments or Responses

Login to post response