entering decimals with keypad

In this reply, posted by PaulS some time ago, is there anyway to limit the number of keypad entries for numbers and decimal point to 5 maximum? eg. 23.50. I only want a maximum number of 99.99. any further numeric key presses would result in the last number changing only

[void loop()
{
   char key = keypad.getKey();
   if(key != NO_KEY)
   {
      if(key == '*')
      {
         index = 0;
         numbers[index] = '\0';
      }
      else if(key == 'D')
      {
         numbers[index++] = '.';
         numbers[index] = '\0';
      }
      else if(key >= '0' && key <= '9')
      {
         numbers[index++] = key;
         numbers[index] = '\0';
      }
      else if(key == '#')
      {
         float len = atof(numbers);
         // Do whatever you need to with len

         index = 0;
         numbers[index] = '\0';
      }
   }
]

Thanks

is there anyway to limit the number of keypad entries for numbers and decimal point to 5 maximum?

Yes. Before you add the character to the array, test that index is less than 4. If it is, add the character and increment index. If not, add the character but do not increment index.