i'm a beginner to java script. can anyone help me in this with this.

if iam the user i want to insert a username in the textbox and it check whether it exist (i can do this in php code) or not..if the username exist it focus on the
username textbox.

Can anyone give me an idea.Thanks a lot..