How can I add a quantity button to my product page?

Anyone know if there is a way to have the quantity selector only go up to the number you actually have in your inventory? I turned it on for my site and tested to see what happened if I added more than what was in stock and it’s an error message that doesn’t really explain it well. I’d prefer to only have it go up to the actual number on hand. I turned it back off in the meantime but it would be nice for people to be able to select quantity prior to adding to cart.