Actually, it is not allowed, and a company should not force anyone to serve notice unless there is mutual agreement and a signed document. If the relationship between the employer and the departing employee is very good, then serving a two-month notice period is acceptable only if both parties agree.
Ninety percent of employees leave organizations because they are unhappy. Naturally, if they are leaving, they won't wait for a two-month notice period.