It is LEGAL to leave them off, in that no law says that you must include every place you work on an application or resume.
However, if any potential employer chooses to take note of the gaps in your resume and eliminate you from consideration because of them, that's legal too.
Some employers would consider those gaps a falsification of your application - a lie by omission, as it were.