How to make a question before form exit

Jose wrote:

I'm makeing a rails aplication where I need to make a qustion to my users like 'Do you want to save changes?' if the user exit of the form without save changes. If this possbile?

Google onunload.