Differential attenuation in star-forming galaxies at 0.3 $\lesssim$ $z$ $\lesssim$ 1.5 in the SHARDS/CANDELS field