jquery - Add exception onclick
<p>I have the following input fields:</p>

<pre><code>&lt;input type="text" value="5" maxlength="12" id="qty" class="input-text qty" name="qty2050" tabindex="1"&gt;
</code></pre>

<p>and </p>

<pre><code>&lt;input type="text" value="0" maxlength="12" id="qty" class="input-text qty" name="qty2042" tabindex="1"&gt;
</code></pre>

<p>I use this code to prevent the user from losing inserted data (upon quitting the page):</p>

<pre><code>&lt;script&gt;
window.onbeforeunload = function() {
    var showAlert = false;
    jQuery('.input-text.qty').each(function (){

        //console.log("fonction 1");
        var val = parseInt(jQuery(this).val(),10);
        if(val &gt; 0) { showAlert = true; } 
        //alert(val);
    });

    //console.log("fonction 2");
    //console.log(showAlert);

    if (showAlert == true) {
        console.log("fonction 3");
        return 'You have unsaved changes!';
    } 
}

&lt;/script&gt;
</code></pre>

<p>I want to add an exception to my submit button, and to not show the alert message when there is a quantity > 0 in one of my input fields.</p>

<p>My problem is in adding this exception!</p>

<p>Thanks for help.</p>
