Measurements of the ZZ production cross sections in proton-proton collisions at center-of-mass energies of 7 and 8 TeV are presented. Candidate events for the leptonic decay mode ZZ -> 2l2 nu. where l denotes an electron or a muon, are reconstructed and selected from data corresponding to an integrated luminosity of 5.1 (19.6) fb(-1) at 7 (8) TeV collected with the CMS experiment. The measured cross sections, sigma(pp -> ZZ) = 5.1(1.4)(+1.5) (stat)(-1.1)(+1.4) (syst) +/- 0.1 (lumi) pb at 7 TeV, and 7.2(-0.8)(+0.8) (stat)(1.5)(+1.9) (syst) +/- 0.2 (lumi) pb at 8 TeV, are in good agreement with the standard model predictions with next-to-leading-order accuracy. The selected data are analyzed to search for anomalous triple gauge couplings involving the ZZ final state. In the absence of any deviation from the standard model predictions, limits are set on the relevant parameters. These limits are then combined with the previously published CMS results for ZZ in 4l final states, yielding the most stringent constraints on the anomalous couplings.