Validator for fractional numbers I used some web resources to find how to make a web page with javascript validator for fractional numbers. What do you think about it? How it can be improved and still look like a web page? Your help will be highly apreciated. Thank you very much!!

&lt;html&gt;
&lt;head&gt;&lt;title&gt;
JavaScript fractional numbers validator
&lt;/title&gt;
&lt;script type="text/javascript"&gt;
    function checkDecimal()
    {
    var res=true;

       var orgValue=document.getElementById("Text1").value;
       var digit=parseFloat(document.getElementById("Text1").value);
        if(isNaN(digit))
        {
          alert("not decimal number");
          res=false;
          return;
        }
        else if(orgValue.charAt(orgValue.length-1)=='.')
        {
          alert("not decimal number");
          res=false;
          return;
        }
        else
        {
           var i=0,count=0;
           for(i=0;i,i&lt;orgvalue.length;i++)&gt;
           {
              var posvalue=parseInt(orgValue.charAt(i));
              if(!isNaN(posvalue))
              {

              }
              else
              {
               posvalue=orgValue.charAt(i);
                if(posvalue=='.')
                {
                  count++;
                }
                else{
                res=false;
                break;
                }
              }
           }
           if(count==0||count&gt;=2)/*if you use If(count&gt;1) the it is work when you enter 12345 then display decimal number.*/
           {
             res=false;
           }
        }
        if(res==true)
        alert("decimal number");
        else
        alert("not decimal number");
    }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name="form1"&gt;
&lt;div&gt;
   Enter Decimal Number: &lt;input id="Text1" type="text" /&gt;
    &lt;br /&gt;&lt;input id="Button1" type="button" value="Check" onclick="checkDecimal();" /&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


It will be great if the code is shorter and eventually possible to have maximum symbols length for the whole part that is different (let's say double) from the fraction part.
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;