JQuery Validation for Two Password Fields
<p>Two entered passwords should be the same, and I want to display a notification when they're not matching. The target is to display the notification during typing and not after pressing the save Button. </p>

<p>I am new to javascript and I have also tried the functionname function() notation.</p>

<p>following js:</p>

<pre><code>function updateError (error) {
if (error == true) {
    $(".error").hide(500);
}else{
 $(".error").show(500);
}
};

function checkSame() {
   var passwordVal = $("input[name=password-check]").val();
   var checkVal = $("input[name=password]").val();
   if (passwordVal == checkVal) {
     return true;
   }
   return false;
};


document.ready(function(){
 $("input[name=password-check]").keyup(function(){updateError(checkSame());});
 $("input[name=password]").keyup(function(){updateError(checkSame());});
});
</code></pre>

<p>and HTML:</p>

<pre><code> @Html.Password("password") 
 @Html.Password("password-check")     
 &lt;span class="error"&gt;Errortext&lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;
</code></pre>

<p>but it doesn't works..
Thx!</p>

<p>Edit:
Now i've changed the JS code to:</p>

<p>$("input[name=password-check]").keyup(function(){updateError(checkSame());});
 $("input[name=password]").keyup(function(){updateError(checkSame());});</p>

<p>--> now it works, but only once, after the user typed a matching password, validation stops working</p>

<p>Solved, problem was Quoting:</p>

<pre><code>$("input[name='password-check']").keyup(function(){updateError(checkSame());});
$("input[name='password']").keyup(function(){updateError(checkSame());});
</code></pre>
