Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2007, 02:27 AM
Authorized User
 
Join Date: Jun 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validate duplicate Entries using javascript

Hi,
I want to validate the value entered in a textbox against the values of a field from a table. The value entered must not be duplicate. Can I scan a table using Javascript.


 
Old July 2nd, 2007, 02:35 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, couldn't get exactly what you are asking for? Are you trying to say that you have fetched value of a field from the database, stored it somewhere, and then trying to compare it with the user entered value in the textbox?

Regards
Mike

Don't expect too much, too soon.
 
Old July 2nd, 2007, 02:50 AM
Authorized User
 
Join Date: Jun 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Say the Product Name is entered in a text box. The product name must be unique. So I'd like to compare it with the values of the ProductName field (from Products table)for duplicate values.

 
Old July 2nd, 2007, 03:31 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, that can't be done using javascript, for that you have to implement a check in your stored procedure, an e.g. can be as below:

IF EXISTS(SELECT TOP 1 1 FROM products WHERE productname = @productname)
    BEGIN
        RETURN -2
    END

The above means that if product name already exists the SP will return -2, then you can check the return code in your programming, and display the message for duplicate product name if return code is -2. Do let us know if you need a sample SP for inserting a new product in products table keeping in mind duplicate values.

Regards
Mike

Don't expect too much, too soon.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing duplicate entries avantikad XSLT 2 January 2nd, 2008 12:29 PM
How not to retrieve duplicate entries? EricTheViking Access ASP 2 January 12th, 2007 08:22 AM
Random Duplicate Entries SaraJaneQ Classic ASP Databases 6 July 16th, 2006 10:47 PM
How can I check for duplicate entries in XML gargkapil777 XSLT 2 December 22nd, 2005 01:00 PM
Delete duplicate entries from table expertcalling SQL Server 2000 2 January 2nd, 2005 11:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.