It's illegal wherever you put it. This is a ridiculous thought experiment that doesn't reflect the reality of regulations on eviction process.
A judge's job is not to apply the law to the letter, but to the spirit. They are not going to throw their hands up when a tenant is kept out of their unit, no matter what the landlord might have decided to sneak in into the rental agreement: the law is there to protect the tenant.