%h1 Change Your Password .form = form_for resource do |f| -if resource.errors.any? #errorExplanation %h2= "#{pluralize(resource.errors.count, "error")} prohibited this change:" %ul - resource.errors.full_messages.each do |msg| %li= msg .field .fieldName Old Password: = f.password_field :old_password, :id=>"old_password" .field .fieldName New Password: = f.password_field :password, :id=>"password" .field .fieldName Confirm Password: = f.password_field :password_confirmation .submit= f.submit "Change Password" :css .extra_form_data { display: none; } = content_for :head do = javascript_include_tag 'jquery.validate' :javascript var checkingPassword = true; $(function(){ jQuery.validator.addMethod("verify_user", function(value, element, params) { //alert($(element).attr('data-verify-user-path')); return $.ajax({ async: false, url: $(element).attr('data-verify-user-path')+ '?password='+value }).responseText == "true"; }, "Password is incorrect."); $('form').validate({onkeyup: function(element) {}}); $('#old_password').rules("add", {verify_user : true, alphanumeric: true}) });