Validator for fractional numbers
How about this one? Representing numbers as object to be able to use the logic for both whole and fraction operations. Also using regexp to check input symbols and length:



function checkNumber() {
  var stringsFromInput = document.getElementById("inputNumber").value.split(/[,\n.]/),
      numbers = [
        {
          name: "whole",
          regexp: /^[0-9]{1,10}$/,
          errorMsg: " number expected to be 10 symbols maximum"
        }, {
          name: "fraction",
          regexp: /^[0-9]{0,5}$/,
          errorMsg: " number expected to be 5 symbols maximum"
        }
      ];
  for (var n in numbers) {
    var name = numbers[n].name,
        value = stringsFromInput[n],
        regexp = numbers[n].regexp,
        msg = numbers[n].errorMsg,
        div = document.getElementById(name + "Div");
        regexp.test(value) ? div.innerHTML = name + " number is OK" : div.innerHTML = name + msg;
  }
}
&lt;form&gt;
  &lt;div class="form-group"&gt;
    &lt;label for="inputNumber"&gt;Enter a number&lt;/label&gt;
    &lt;input type="string" class="form-control" id="inputNumber" placeholder="123456789.54321"&gt;
    &lt;button type="button" onclick="checkNumber()"&gt;Check&lt;/button&gt;
  &lt;/div&gt;    
  &lt;div id="wholeDiv"&gt;Status will&lt;/div&gt;
  &lt;div id="fractionDiv"&gt;appear here&lt;/div&gt;
&lt;/form&gt;