以下代码显示除了空白密码确认字段之外的所有内容的“密码不匹配”,无论密码字段包含什么。我不确定我要去哪里错了。
查看(rails form_for):
<%= form_for @user, :url => user_registration_path do |f| %>
<%= f.password_field :password, :class=>"span-live", :maxlength=>"50", :placeholder=>"Create Password*" %>
<%= f.password_field :password_confirmation, :class=>"span-live", :maxlength=>"50", :placeholder=>"Confirm Password*" %><br>
<div id="validate-password-status"></div></div>
Javascript(custom.js):
$(document).ready(function() {
$("#user_password_confirmation").keyup(validatePassword);
});
function validatePassword() {
var password = $("#user_password").val();
var password_confirmation = $("#user_password_confirmation").val();
if(password == password_confirmation) {
$("#validate-password-status").text("Passwords match");
}
else {
$("#validate-password-status").text("Passwords do not match");
}
};