OKCOOL

Back

jQuery AJAX username availability lookup

One of the key design goals of our new Simple Web Management platform is ease of use. We want to deliver a joyous user experience.

If you read my post on password generation using twitter you will know I’m currently working on the process of adding users to the system. A neat little user experience trick I like, that you’ve no doubt seen elsewhere, is to check the availability of a username as the user is typing.

Availability

Looking up the username on the server and returning a response via AJAX is pretty simple (especially with JQuery), but every time the function is called a lookup on the user table is processed. Therefore, we don’t really want to do a lookup every time the user presses a key.

The first solution to the problem of this could be to add a ‘check availability’ link next to the username field, but this is a bit… erm… scrappy. The best option would be to wait until the user has stopped typing for a while. Well, thanks to a great little jQuery plugin called TypeWatch this is a doddle.

Here is my code. You’ll need jQuery and the TypeWatch plugin to make this work. Assumptions – my username field is ID’d Username, the AJAX query returns the text of the availability and puts it in to a span ID’d usernameAvailability.

  • Tom
  • 5 April 2008
  • 3 comments

Comments

JQuery plugins for the SEO • Tim Nash UK SEO Blog

said on 8 April 2008

[...] rules makes it a breeze to validate almost any form. Works particularly well when combined with user name availability [...]

Anthony Kosednar

said on 6 September 2008

Hey is there any chance that you could release the script for the random twitter password too? I would love to use that.. with credit of course.

Tom

said on 6 September 2008

Hey Anthony

Glad you like it.

I’ve got quite a lot of dev on my plate at the moment with some of the SWIM stuff (http://www.simpleweb-online.com/) we’re up to. I’m working tomorrow though so if I get a spare moment I’ll dig it out. Drop me an email to taholder[at]gmail[dot]com and I will forward it on – it’s in PHP

Add a comment





OKCOOL Wordpress theme created by OKCOOL