In the US, the questions are not per se a violation of the law, but you are treading on very thin ice because using the answers to such questions in a way that has a disparate impact on anyone because of their gender, age, family status, religion, etc is a violation of the law, even if you did not intend to discriminate against people on that basis.