Redbacks (RBs) and black widows (BWs) are two peculiar classes of eclipsing millisecond pulsars (MSPs). The accretion-induced collapse (AIC) of an oxygen/neon/magnesium composition white dwarf to a neutron star has been suggested as one possible formation pathway for those two classes of MSPs. However, it is difficult to produce all known MSPs with the traditional AIC scenario. In this study by using the MESA stellar evolution code, we investigate the detailed pre-AIC evolution of magnetized white dwarf binaries with the magnetic confinement model where the high magnetic field strength of the white dwarf can confine the accreted matter in the polar caps. We find that the initial donor mass and orbital periods in our model can be lower than that of previous traditional AIC models. We also present post-AIC evolution models to form RBs and BWs with and without the spin down luminosity evaporation of MSPs. Under the magnetic confinement model and evaporative winds (with corresponding angular momentum loss from the surface of the donor star), the companion masses and orbital periods of all known RBs can be covered and a number of binaries can evolve to become BWs.