A Defendant can challenge improper venue by moving to transfer venue to another court before or concurrently with its response to the complaint. CCP Section 396b(a) It should be noted that raising the issue as an affirmative defense in your answer is inadequate.
Failure to challenge in a timely manner waives any objection to the Plaintiff’s improper venue selection. Improper venue is not a jurisdictional defect and does not present grounds for collaterally attacking a judgment.