validating input widgets
[This may be a well-worn old question -- apologies if so, but I have no idea how to search for it.]
First, the background. (This is not the question yet.) Suppose I've got a GUI with an input widget where the user can input a number. And suppose I am allowing the user to type on the keyboard; I'm not constraining things utterly with a prescribed selection list, or +/- buttons to merely adjust an existing value.
Among other things, I'll probably want to validate the user's input, to ensure it's in the appropriate range. For example, perhaps the user is entering the desired speed for a motor, which is limited to the range 0 - 1500 RPM.
Now, there are sort of two general approaches to implementing the validation:
Let the user type more or less anything, but after clicking OK, if the input is not valid, pop up a warning dialog to that effect, forcing the user to cancel or try again.
Contrive to not even let the user type an invalid input in the first place.
And I suppose it's possible to do various combinations, like only allowing digit keys to be typed, but waiting until OK is clicked before checking the actual value.
In the first case, that warning dialog is arguably a nuisance. It's additional work for the programmer to code it up, and it's an interruption for the user, who has to stop and think and figure out what to do next. (OK? Cancel? Or what?)
But in the second case, there's a subtle potential problem, too. Suppose the current value is, say, 160 (which is well within range). Suppose the user wants to change it to 170. Suppose the user chooses to do this by clicking to set the text cursor between the 1 and the 6, and typing 7 and then the forward-delete key to delete the 6.
But of course this means that for a moment the dialog will say 1760, which is out of range, so this input sequence is disallowed.
So in the second case, which seems generally friendlier in many respects, there's this sort of bizarre hidden constraint on what the user is allowed to type. Occasionally when using such input methods (I wish I could remember a better example), it's been like a miniature impromptu brainteaser puzzle, to figure out a reasonably minimal sequence of keystrokes sufficient to change the value I have into the value I want, without ever passing through any intermediate states where the instantaneous displayed value is disallowed.
So, now, the questions: (1) Do these two rather different styles of input validation have names? (2) Are there other tradeoffs between them, beyond the two I've mentioned? And, (3) if the second method is preferred, is the problem of having to solve occasional little puzzles as I've described something that isn't expected to come up very often, or that users will just have to put up with, or what?