samedi 4 avril 2015

JavaScript IF statement not working when comparing strings

A simple string compare is simply not working



//Get the new passwords
var newPassword = "hello";
var newPasswordConfirm = "hello";

$('#password_div').html("newPassword: " + newPassword +", confirm: " + newPasswordConfirm);

if (newPassword == newPasswordConfirm) {
$('#passwordDialog').modal('hide');
}


The IF statement is always false, even though the output shows both strings the same. Any idea why?


Aucun commentaire:

Enregistrer un commentaire