How can I check that an input textbox has a float value with no more than 3 places after the point in javascript?
4 Answers
thank u guys But i made the solution in a much simpler way : 1st wrote this function ----> //Checking A value is 3 decimal palce or not
function chkplace3(ctrl,msg) {
var dot="."
var val = ctrl.value;
var len=val.length
var ldot=val.indexOf(dot)
var diff=(len-ldot)
if(diff>4)
{
alert(msg + ' can not be more than 3 numeric places');
ctrl.focus();
return false;
}
return true;
}
and then calling with the reqd parameter from the form --->
if(!chkplace3(document.from.txtfield,'msg')) { return false; }
1 Comment
NickFitz
That would allow me to enter "abc.def". The regular expression solutions posted by myself and others also check that only digits (0 - 9) are entered.