I'm no javascript expert, but a couple of things to keep in mind. SSI_GetValue should be used for any question on the current page. If the question is on a previous page you need to use Sawtooth Script [% %] to call that question's response. Given that, I have assumed that all questions are on previous pages except for D52. In the following script I first set a variable that adds the question HHmembers, the value of 1 and A15 together. Then the if statement is looking to execute if A4b1 is a 2 and the variable totmembers does not equal the response to D52. If those assumptions are correct, I believe I have the below javascript correct.
var totmembers = [% HHmembers %] + 1 + [% A15 %]
if([% A4b1 %]==2 && (totmembers != SSI_GetValue('D52'))
{
strErrorMessage = 'Please verify # of people in home.';
}