i'm testing a password confirmation validation. when im using this code with variables, it doesn't work:
$(function() {
var pass1 = $("#reg-password").val(),
pass2 = $("#reg-password2").val();
$("#reg-password2").blur(function(){
if (pass1 != pass2){
alert ('Doesnt Match');
}
});
});
But this one works, why?
$(function() {
$("#reg-password2").blur(function(){
if ($("#reg-password2").val() != $("#reg-password").val()){
alert ('Doesnt Match');
}
});
});