# Ajax live valiation on username

**URL:** <https://www.ruby-forum.com/t/ajax-live-valiation-on-username/149594>\
**Category:** Rails\
**Created:** [September 26, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/ajax-live-valiation-on-username/149594 "2008-09-26T16:59:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [September 26, 2008, 4:59pm UTC](https://www.ruby-forum.com/t/ajax-live-valiation-on-username/149594/1 "2008-09-26T16:59:52Z")

</div>

This has probably been definitively answered elsewhere (it applies to  
the default setup for restful\_authentication), but I haven’t been able  
to track the solution down. My User model has a unique ‘username’ (or  
:login, as it’s known in RA) attribute, and it’s going to be very  
annoying for users to have to wait until a form is posted to find out  
that their chosen username is already taken. Does anyone know of an easy  
route for doing client side validation on this attribute? I think it’s  
the only attribute I need to do the client side validation on, and I  
just want it to confirm whether or not a username is available, on the  
fly…

Any plugins, blog posts, quick tips?

I found this post but, knowing the pace of Rails and considering it was  
posted almost two years ago, I’m betting there’s something newer out  
there, plus it doesn’t come with any specs;

[http://www.davidjrice.co.uk/articles/2006/11/29/inline-ajax-form-validation-plugin-for-ruby-on-rails](http://www.davidjrice.co.uk/articles/2006/11/29/inline-ajax-form-validation-plugin-for-ruby-on-rails)

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [October 3, 2008, 10:18am UTC](https://www.ruby-forum.com/t/ajax-live-valiation-on-username/149594/2 "2008-10-03T10:18:01Z")

</div>

Neil C. wrote:

> This has probably been definitively answered elsewhere (it applies to  
> the default setup for restful\_authentication), but I haven’t been able  
> to track the solution down. My User model has a unique ‘username’ (or  
> :login, as it’s known in RA) attribute, and it’s going to be very  
> annoying for users to have to wait until a form is posted to find out  
> that their chosen username is already taken. Does anyone know of an easy  
> route for doing client side validation on this attribute? I think it’s  
> the only attribute I need to do the client side validation on, and I  
> just want it to confirm whether or not a username is available, on the  
> fly…
> 
> Any plugins, blog posts, quick tips?
> 
> I found this post but, knowing the pace of Rails and considering it was  
> posted almost two years ago, I’m betting there’s something newer out  
> there, plus it doesn’t come with any specs;
> 
> [http://www.davidjrice.co.uk/articles/2006/11/29/inline-ajax-form-validation-plugin-for-ruby-on-rails](http://www.davidjrice.co.uk/articles/2006/11/29/inline-ajax-form-validation-plugin-for-ruby-on-rails)

Update: These are probably the easiest tutorials to follow;

[http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/observe\_field](http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/observe_field)  
[http://weblogs.java.net/blog/bleonard/archive/2008/04/autovalidation.html](http://weblogs.java.net/blog/bleonard/archive/2008/04/autovalidation.html)

Just make sure you manage your :validate action in relation to any  
before filters you may have in your users controller.
