Validate 1st field on form

Discussion in 'ASP General' started by Marius, Sep 9, 2003.

  1. Marius

    Marius Guest

    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
     
    Marius, Sep 9, 2003
    #1
    1. Advertising

  2. Marius

    Bob Barrows Guest

    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

    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?
    >
    > thanks
    >
    > marius
     
    Bob Barrows, Sep 9, 2003
    #2
    1. Advertising

  3. Marius

    Dan Brussee Guest

    On 9 Sep 2003 07:22:34 -0700, (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.
     
    Dan Brussee, Sep 9, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page