Let (Σ, g) be a compact Riemannian surface. Let ψ, h be two smooth functions on Σ with Σ ψdv g 0 and h ≥ 0, h 0. In this paper, using a method of blowup analysis, we prove that the functionalis bounded from below in W 1,2 (Σ, g). Moreover, we obtain a sufficient condition under which J ψ,h attains its infimum in W 1,2 (Σ, g). These results generalize the main results in [9] and [25].