"totally invalid"? Well, it depends on the situation.
In some cases, substantive theory indicates that there is a linear relationship between two variables (or a quadratic one, or whatever) and regression is used to confirm that relationship and make its estimates precise. Here, some extrapolation may be OK
How far out of the range of the data are you extrapolating? If you have data on (say) the heights and weights of adult men, and your tallest man is 6'5" and you extrapolate to 6'7" you are probably OK. But you may be off if you extrapolate to the tallest people on Earth.
How strong is the relationship? A relationship where all the data are close to a line is going to be easier to extrapolate from than one where the data are only approximately on the line.
How much of a range of data have you got? Continuing the height/weight example, if you have data on men from 5'1" to 6'5" I'd be more likely to trust extrapolation than if you only had it on men from 6'3" to 6'5"?
What is the nature of the relationship? Polynomial relationships can go way off very quickly.
etc.