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!!<html><head><title>JavaScript fractional numbers validator</title><script type=text/javascript>    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<orgvalue.length;i++)>           {              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>=2)/*if you use If(count>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);    }</script></head><body><form name=form1><div>   Enter Decimal Number: <input id=Text1 type=text />    <br /><input id=Button1 type=button value=Check onclick=checkDecimal(); /></div></form></body></html>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.
Validator for fractional numbers
javascript
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;  }}<form>  <div class=form-group>    <label for=inputNumber>Enter a number</label>    <input type=string class=form-control id=inputNumber placeholder=123456789.54321>    <button type=button onclick=checkNumber()>Check</button>  </div>      <div id=wholeDiv>Status will</div>  <div id=fractionDiv>appear here</div></form>