Limiting Mouse

I used the tutorial on how to make a MC follow my mouse now how do I confine it to a certain area on the page and how do i make it look like it is attached with an invisble rubber band that makes it assume it’s original position?

Thanks,