protected int validateInput(String input, int numDigits)
    {
        if(input.equals(""))
        {
            return 0;
        }
        
        boolean negative = false;
        
        input = input.trim();

        if(input.charAt(0) == '-')
        {
            negative = true;
        }

        //Goes through the input string and converts any non-digit characters to
        //  0.
        for(int count = 0; count < input.length(); count++)
        {
            if(!Character.isDigit(input.charAt(count)))
            {
                input = input.replace(input.charAt(count), '0');
            }
        }

        //After changing all characters to digits, trims leading 0's from the 
        //  string.
        if(Integer.parseInt(input) != 0)
        {
            while(input.charAt(0) == '0')
            {
                input = input.substring(1);
            }
        }

        //If the resulting string is too long, truncate until only the 3 left 
        //  most digits remain.
        while(input.length() > numDigits)
        {
            input = input.substring(0, input.length() - 1);
        }

        if(negative)
        {
            return Integer.parseInt(input) * -1;
        }
        else
        {
            return Integer.parseInt(input);
        }
    }