Ask a Business Lawyer. Get Business Law Questions Answered ASAP.
Yes, totally legal. Every gated community in America bans non residents from entering the development unless as a guest of a resident.
The property is private property and they can have whatever rules they want, as long as the don't violate civil fair housing rights (for example, the couldnt make an all white subdivision).
I know this is not what you hoped to hear, but just try to be honest and give it to you striaght, rather than just tell you what you want to hear only for you to be disappointed later.