Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:49:49+00:00 2026-06-10T07:49:49+00:00

When a form is being submitted, I need to check if a duplicate already

  • 0

When a form is being submitted, I need to check if a duplicate already exists. If it does, it stops the form from being submitted and allows the person to edit the fields again. I have never really used ajax before, but I have read that for something like this, it would be the best to use. I also can not use PHP, but can use javascript and asp. Right now, I am able to check the database if duplicate values already exist by doing the following:

var  SQL =  " SELECT COUNT(LeaveID) AS Dup, personalID, StartDate, EndDate, StartTime, EndTime, LeaveType";
     SQL += " FROM onLeave";
     SQL += " WHERE personalID = " + ipersonalID;
     SQL += " GROUP BY personalID, StartDate, EndDate, StartTime, EndTime, LeaveType";
     SQL += " HAVING COUNT(LeaveID) > 1";
     SQL += " ORDER BY StartDate DESC";
var rs = Connection.Execute(SQL);

writeTable(rs)

writetable(rs) just outputs the data into a html table and ipersonalID is the current ID of the person viewing the page. The submit is just a simple input like below:

<input type="button" name="btnSubmit" value="Submit" onclick="submitSkedChange()" id="btnSubmit"/>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:49:51+00:00Added an answer on June 10, 2026 at 7:49 am

    I agree with the comment from @asawyer. A better approach is to add the unique constraint to the table and let it fail. On code behind you simply catch the Exception and display the error to the user. You can specifically catch the Violation of unique constraint error and act accordingly. For any other error, you’d have to decide what to do.

    The above approach has several benefits IMO:

    1. One less DB call.
    2. Should perform better because of above and by not having to make an ajax call
    3. It enforces data integrity at the DB level, which is a good thing.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic POST form being submitted. Every time a form is submitted,
how can i get the parameters of any form being submitted with method=post before
How would i go about stopping a form from being moved. I have the
What is the best way to stop a form from being reprocessed when a
I have got a textbox on a form with a method being called from
I have a contact form that is being submitted, I have PHP validation all
I have a form which is being submitted by ajax. Before submission, there's a
I've got a form inside an <asp:Content> block that is being submitted to a
I have a form being submitted for a complex model including many associations. I
I have a timesheet in a browser-compatible InfoPath 2010 form, which is being submitted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.