Here in France, and probably lot of places in Europe, a 3-months notice period is required after informing your employer of your resignation. During this period, you finish the things you started, they find your substitute, you train your substitute, they write all the legal papers properly, you prepare for your next job and so on.
3 months can be long but the working conditions become super cool (e.g. 10-4 instead of 9-5).
The same conditions apply if your employer fires you (which is relatively rare, unless you commit serious misconduct). You stay 1 or 2 more months in the company after being informed, so you can find another job before leaving.
(Note: during the first months in the company, you are in a trial period so these rules don't apply. You leave when you want and they fire you when they want.)