How to get past a forgotten iPhone passcode? I forgot my iPhone 5 passcode when I was changing the code. A window appeared on the device screen saying that iPhone is disabled.

I have Apple ID and password for it. After signing in to iCloud I have erased the device in order to remove the passcode from my iPhone but it still says that device will be erased when device will connect to internet. What would i have to do?
Connect the device to a Mac over USB and restore it using Finder. Since you have control of the AppleID that locks that device, you only need to get it connected to a network again. You can also see the last backup date online and know how much data might be lost in a restore.

Once the restore process is complete, you can restore the backup or just set up the phone as new. The apps, data, passcode will all be erased.