
Hm. Javascript alone does not do this, as you first need to connect to the users table and verify the name is available. Perhaps JS would be used to then alert the user that the name is taken, but the actual hitting-the-database-and -checking would be performed by something else; in a JS world, likely jQuery...