Checking if any input or textarea element in the page is not empty
<p>I'm adding a mechanism in my website that's supposed to warn users whenever they are about to close a page they were working in. I'm binding a function <code>dropDraftConfirmation</code> to the <a href="https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload" rel="nofollow"><code>window.onbeforeunload</code></a> event, like this:</p>

<pre><code>window.onbeforeunload = dropDraftConfirmation;

function dropDraftConfirmation()
{
    if (&lt;there is an input or textarea element not empty on the page&gt;) {
        alert('Your changes will be lost. Are you sure you want to exit the page?');
    }
}
</code></pre>

<p>But this is called every time I close a page. So my question is, how to detect if there is an input or textarea element in the page that is <em>not</em> empty? I'm using <a href="http://jquery.com/" rel="nofollow">jQuery</a> by the way.</p>
