Comparing multiple field values ​​together
<p>How can I compare multiple input field values and if there is a match alert 'There are similar values' using jQuery?</p>

<pre><code>&lt;input value="111"&gt; //similar
&lt;input value="222"&gt;
&lt;input value="111"&gt; //similar
&lt;input value="333"&gt;
</code></pre>

<p>This html code above should alert 'There are similar values', as it has 2 values which are the same. How can it be done with jQuery?</p>

<p>My tried(Following code doesn't work):</p>

<p><strong>DEMO:</strong> <a href="http://jsfiddle.net/HpWLQ/" rel="nofollow">http://jsfiddle.net/HpWLQ/</a></p>

<pre><code>$('input').each(function () {
    var $this = $(this);
    var val = $this.val();
    vals.push(val);
});
for (var i = 0; i &lt; vals.length; i++) {
    for (var n = 0; n &lt; vals.length; n++) {
        if (n !== i) {
            if (vals[i] === vals[n]) {
                alert('There are similar values');
            }
        }
    }
}
</code></pre>
