I got started by following this awesome tutorial, but wanted to do the validation on on keyup and place my errors somewhere else. The remote validation shows its own error message at the appropriate times, making me think I had it working. But if I ask specifically if a field with remote validation is valid, it says no, actually, its not.
In application.js I have this...
$("#new_user").validate({
rules: {
"user[login]": {required: true, minlength: 3, remote: "/live_validations/check_login"},
},
messages: {
"user[login]": {required: " ", minlength: " ", remote: " "},
}
});
$("#user_login").keyup(function(){
if($(this).valid()){
$(this).siblings(".feedback").html("0");
}else{
$(this).siblings(".feedback").html("1");
}
})
And then this in the rails app...
def check_login
@user = User.find_by_login(params[:user][:login])
respond_to do |format|
format.json { render :json => @user ? "false" : "true" }
end
end
I think that my problem might have everything to do with this ticket over at jQuery, and tried to implement that code, but, being new to jQuery, it's all a bit over my head. When I say bit, I mean way way.
Any ideas to fix it, or a new way to look at it, would be a big help.