function isValid(str){
var
lastIndex = str.length - 1,
findIndex = str.indexOf('.'),
count = null;
if( findIndex == -1 ){
return true;
}
else {
count = lastIndex - findIndex;
return count == 1 || count == 2;
}
}
console.log(isValid('123')) //true
console.log(isValid('123.')) //false
console.log(isValid('12.3')) //true
console.log(isValid('1.23')) //true
console.log(isValid('0.123')) //false
console.log(isValid('1.100')) //false