function validate_decimal(obj)
{
  txt1=obj.value;
  var Chars = "0123456789.";
  var CharDot = ".";
  var flag = 0;

  // this will get rid of leading spaces
  while (txt1.substring(0,1) == ' '){
     txt1 = txt1.substring(1, txt1.length);
     obj.value = txt1;
  }
  // this will get rid of leading zeroes
  while (txt1.substring(0,2) == '00'){
     txt1 = txt1.substring(1, txt1.length);
     obj.value = txt1;
  }
  // add a zero if the first character is a dot
  if (obj.value!="" && (CharDot.indexOf(txt1.charAt(0)) != -1)){
      txt1 = "0" + txt1;
      obj.value = txt1;
  }

  for (var i = 0; i < txt1.length; i++)
  {
     if ((Chars.indexOf(txt1.charAt(i)) == -1))
     {
         obj.value = "";
         obj.focus();
         alert("Only number 1 to 9 and character . are allowed");
         return false;
     }
     if ((CharDot.indexOf(txt1.charAt(i)) != -1))
     {
         flag += 1;
         if ((txt1.length-i) > 3){
            txt1 = txt1.substring(0, txt1.length-1);
            obj.value = txt1;
            obj.focus();
            alert("Please enter the correct format (eg. 3.00). Please enter 2 decimals place.");
            return false;
         }
         if (flag > 1){
            txt1 = txt1.substring(0, txt1.length-1);
            obj.value = txt1;
            obj.focus();
            alert("Please enter the correct format (eg. 3.00). Please enter only 1 dot.");
            return false;
         }
     }
  }
  //obj.value = txt1;
  return true;
}
