js Code
var old = "";
function check(ele) {
var pattern = /^(\+|\-)?((([1-9]([0-9]*))|0)(\.[0-9]*)?)?$/;
var val = ele.value;
if(val.match(pattern)) {
old = val;
return true;
} else {
ele.value = old;
return false;
}
}
html Code
< input type= "text" size= "20" onkeyup= "check (this)" >
how does this rule retain two decimal places