If I am making a text box for an online document, how many characters should I leave for things like names and dates?
For a date, it's pretty easy once you have chosen the format.
The format YYYY/MM/DD requires a minimum of 10 characters.
For things like name and surnames, you should consider the longest surname and name your country has. If it is international, just put it up to 32 characters as most websites do.
For some values, there's a defined length or maximum length. Like US Zip Codes are 5 digits, or 10 digits if you allow for zip-plus-4 and they hyphen. Credit card numbers are typically 16 digits. Etc.
Of course many values aren't controlled by some central authority and don't have defined lengths. A person's name would be an obvious example. In these cases, all you can really do is look at available examples and come up with a length that should be big enough most of the time. There's no rigid formula. 10 characters is surely too short for a last name. 500 is almost certainly excessive. Most people allow 30 or so.
How big a problem is it if you can't fit the longest possible value? I don't know what the longest name in the world is. I'd guess it's something ridiculously long, probably unwieldy to allow for. If it turns out that ten people in the world have names that are 500 letters long, are you going to make your "name" box 500 characters wide? Probably not. Surely if someone has a name that long and has used computer or paper forms before, he's used to running out of space by now and has figured out some way to abbreviate.
Bear in mind that textboxes on modern computer systems don't necessarily limit the user to text that will fit in the box: they'll scroll to the right as you type. So if you allow 30 characters for whatever value and someone has an unusual case where they need 35, so it will scroll. Inconvenient, perhaps, but not a huge big deal.