title: Confirm alert when leaving page if form is filled
body: <p>I need help. I want to display confirm alert if user leave page and if form is filled or at least some of the fields on form are filled. I have following code that is functioning in Chrome but not working in Firefox. Also the alert is displayed even when the form fields are empty.</p>
  
  <p>Following is my code,</p>
  
  <pre><code> $(window).bind('beforeunload', function () {
              return ''; //Are you sure you want to leave?';
          });
  </code></pre>
  
  <p>So I need help so I can produce alert in Firefox, and all other browsers when form is completely or partially filled but not produce any alert when form is empty. I tried making use of viewstate. Checking if viewstate value is different then produce alert, but it's not working as I expected</p>
  
  <p>another piece of code I tried is</p>
  
  <pre><code> window.onbeforeunload = function (e) {
    var message = "Your confirmation message goes here.",
    e = e || window.event;
    // For IE and Firefox
    if (e) {
    e.returnValue = message;
    }
  
      // For Safari
    return message;
  </code></pre>
  
  <p>};</p>
  
  <p>But the above code does not check if form  is filled or not. I want alert when form is partially or completely filled</p>