A search for invisible decays of Higgs bosons is performed using the vector boson fusion and associated ZH production modes. In the ZH mode, the Z boson is required to decay to a pair of charged leptons or a b b-bar quark pair. The searches use the 8 TeV pp collision dataset collected by the CMS detector at the LHC, corresponding to an integrated luminosity of up to 19.7 inverse femtobarns. Certain channels include data from 7 TeV collisions corresponding to an integrated luminosity of 4.9 inverse femtobarns. The searches are sensitive to non-standard-model invisible decays of the recently observed Higgs boson, as well as additional Higgs bosons with similar production modes and large invisible branching fractions. In all channels, the observed data are consistent with the expected standard model backgrounds. Limits are set on the production cross section times invisible branching fraction, as a function of the Higgs boson mass, for the vector boson fusion and ZH production modes. By combining all channels, and assuming standard model Higgs boson cross sections and acceptances, the observed (expected) upper limit on the invisible branching fraction at m[H] = 125 GeV is found to be 0.58 (0.44) at 95% confidence level. We interpret this limit in terms of a Higgs-portal model of dark matter interactions.