We present high-resolution optical spectra obtained with the Ultraviolet and Visual Echelle Spectrograph at the Very Large Telescope and 21-cm absorption spectra obtained with the Giant Metrewave Radio Telescope and the Green Bank Telescope of five quasars along the line of sight of which 21-cm absorption systems at 1.17 < z < 1.56 have been detected previously. We also present milliarcsecond-scale radio images of these quasars obtained with the Very Large Baseline Array. We use the data on four of these systems to constrain the time variation of x ≡ gpα2/μ, where gp is the proton gyromagnetic factor, α is the fine structure constant and μ is the proton-to-electron mass ratio. We carefully evaluate the systematic uncertainties in redshift measurements using cross-correlation analysis and repeated Voigt profile fitting. In both cases, we also confirm our results by analysing optical spectra obtained with the Keck telescope. We find the weighted and the simple means of Δx/x to be, respectively, −(0.1 ± 1.3) × 10−6 and (0.0 ± 1.5) × 10−6 at the mean redshift of 〈z〉 = 1.36 corresponding to a look-back time of ∼9 Gyr. This is the most stringent constraint ever obtained on Δx/x. If we only use the two systems towards quasars unresolved at milliarcsecond scales, we get the simple mean of Δx/x = +(0.2 ± 1.6) × 10−6. Assuming the constancy of other constants, we get Δα/α = (0.0 ± 0.8) × 10−6, which is a factor of 2 better than the best constraints obtained so far using the many-multiplet method. On the other hand, assuming that α and gp have not varied we derive Δμ/μ = (0.0 ± 1.5) × 10−6 which is again the best limit ever obtained on the variation of μ over this redshift range. Using independent constraints on Δα/α at z < 1.8 and Δμ/μ at z ∼ 0.7 available in the literature, we get Δgp/gp ≤ 3.5 × 10−6(1σ).