Create step by step form

I'm trying to make a form divided in multiple steps but on the same page. And in order to advance to the next step, certain conditions must be met. For instance, you can't advance to the next phase of a form unless certain fields are filled.

I'd like to know which is the best pattern to do this.