I suggest that you have a comparator. One input of the comparator needs to be connected to the digital input and the other input connected to a switchable voltage. If the comparator operates, the digital input is too high or the setting is too low.
That needs a comparator that can handle up to 24 V, which might be difficult. You could divide the input voltage by 10 with a potential divider, and then compare to smaller voltages, for instance 0,5, 1.2 and 2.4 V to correspond to 5, 12 or 24 V inputs.
A circuit like that will not give any indication of the voltage setting being wrong if the digital input happens to be off. An input at 0 V could be a 0V / 5 V digital input that is off, or it could be a 0V / 24 V digital input that is off.