observe_field is your friend here. Alternatively try a search for "live
search" or something similar.
An example (Untested)
<%= text_field "user", "name" %>
<div id="user_name_result"
style="display:none"></div>
<%= observe_field "user_name", :url => { :controller =>
''user'', :action =>
''check_user_name'' }, :update =>
''user_name_result'', :on => ''changed'',
:complete => "new Effect.Show(
''user_name_result'')" %>
Additionally you can use the link_to_remote options. eg :loading, :complete
etc
Then in your controller you have a method
def check_user_name
@user = User.find_by_name( params[:user][:name] ) || User.new
if @user.new_record?
render :inline => "Div contents to indicate that the name is
available. This will go in the div" and return
else
render :inline => "Div contents to indicate that it''s
taken"
end
end
On 6/9/06, David <lists@codecharter.com> wrote:>
> Hello,
>
> I''ve created my user model which validates against the database
for a
> proper user/pass combination. I''ve set validation options to
ensure that
> both a user and password are entered.
>
> I would like to check via an ajax call whether or not the username is
> taken. I haven''t been able to find a tutorial covering this
topic. Do
> any of you know of one?
>
> Thanks,
> David
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060609/e2e9b57b/attachment-0001.html