If you buy an iphone 5 on a network with a contract can you leave?

Like if I were to buy the iPhone 5 on a contract with sprint and then took the SIM card out and left there network to go to somewhere else would that work?

Added (1). But I also heard it illegal to "unlock" your phone or whatever

No idea?

Yeah go ahead. It's that easy.

just go ahead and get the sprint iPhone 5 on contract and switch the sim. And you're done.

Not exactly.
First, if you signed a contract then decided you did not want to stay with them, you would be charged an early termination fee, which is around 350 and then decreases based on how far into your contract you are.

Second, different carriers use different technologies. For instance, Sprint and Verizon use what is called CDMA, and they do not use a SIM card. So you could not use an iphone meant for sprint on Atts network, as they use a technology called GSM, which does use SIM cards. And just an FYI, Verizon (and I believe sprint) do use a SIM card but solely for the 4G Internet.

Also, the last time I heard (the law on this has been talked about frequently) it is illegal to unlock a phone yourself. The carrier can do it for you, but they most likely will not unless your contract is up, as they want you to stay with them.

So in short, it is possible, but may be slightly annoying to do so.