Valency: Valency may also be define as number of valence electron present in outer most shell.
Valency of chlorine: Atomic no. =17
Configuration :2,8, '7 '= (8-7=1) valency is 1
Valency of Magnesium: Atomic number = 12
Configuration : 2, 8, 2 , so valency = 2