FSM (Finite state machine) modelling of a web page's states using jQuery
<p>I am interested in how the kind of behaviour described below, may be implemented, using jQuery.</p>

<p><strong>Technical overview:</strong></p>

<p>Technically, the behaviour is best modelled by a state machine thus:</p>

<p>A page is loaded up and is in an initial state (state A). A page in state A places no restriction on the user, in that a user can do whatever he likes, on the page. Once the page is in state B (arrived at by clicking a specific button/link etc), the user needs to carry out a specific sries of steps (typically correctly filling out a form and submitting it), in order to bring the page back to it initial state. In other words, correctly submitting the form brings the page back to the initial state (State A)</p>

<p>Whilst in state B, any attempt by the user to move away from the page or click another link on the current page etc, will result in a messagebox (or JQuery messagebox) popping up and asking the user to confirm (Yes, Cancel) if they want to move away from the current task.</p>

<p><strong>An example in practise:</strong></p>

<p>A page is displayed, which presents a button for a user to click on, in order to fill in some required information. The user may chose to ignore the button, and carrying on with browing the site. However, once the user clicks the button and starts entering the information, if they (intentionally or intentionally) were to move away from the task (i.e. to do anything that would cause the current page to be refreshed/reloaded), then a message box should popup and ask the user to confirm if this is indeed what they want to do. A good example of such behaviour is actually found on this website, when you click the 'Ask Question'  "button".</p>

<p>I would like to know how to implement such behaviour, using the functionality provided by jQuery.</p>
