Answer
It is not advisable to take medication to stop the menstruation without a pressing need, as that is harmful to health. However, if you take the medication and fast, your fasts will obviously be valid.
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai