Validate 1st field on form

M

Marius

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?

thanks

marius
 
B

Bob Barrows

a) You could use an XML data island. Here's an example (you will need to
modify it for your purpose - the intent is simply to demonstrate how to pass
the XML to the client):
http://www.davidpenton.com/testsite/tips/xml.data.islands.asp

b) You could pass a recordset to the client using XML like this:
http://www.davidpenton.com/testsite/tips/xml.recordset.server2client.asp,
allowing you to use rs.Find to see if the user has entered a previously-used
name.

c) You could use the XMLHTTPRequest object to pass the user name to another
asp page which determines whether or not it is already used and returns the
result to the calling page.

HTH,
Bob Barrows
 
D

Dan Brussee

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top