On 9 Sep 2003 07:22:34 -0700,
ma**********@ananzi.co.za (Marius)
wrote:
Hi
I have a form that users fill in, thefirst field is a username, which
must be unique.
Currently only when I attempt the Insert into the DB does the restaint
inform the user that it already exists.
Is there any way i can check , let say onblur, if that username
exists, so that they dont have to complete the whole form before being
informed?
To do this, you would need one of the following on client side.
A. A list of all current usernames. Probably not practical, plus it
would reveal all usernames to anyone who wanted to look at the source
code :)
B. A way to look up a name quickly on the server. There are a couple
ways of doing this, but the concept of "quick" is relative here. In
all but the best conditions, the turnaround time may be more than what
you want to handle "onblur".
You need to balance the steps you take with the expected value.
Assuming you repopulate the form if a username is not unique, I would
say you are doing fine - especially if you are using a stored
procedure to do the insert. This way, you can check for an existing
username before actually attempting the insert.