Accessibility Compliance
SurveyJS libraries meet a variety of WCAG and Section 508 standards. Run AXE® Validation to assess this demo’s accessibility level.

Detect Duplicate Form Records

Edit in →

Duplicate detection checks whether a newly entered record matches—or is likely to match—an existing record, helping prevent duplicate patients, customers, or registrations. Unlike mis-keyed variation detection, which flags possible spelling mistakes, duplicate detection determines whether the person or organization already exists and whether a new record should be created.

To implement duplicate detection in SurveyJS, handle the onServerValidateQuestions event, compare the submitted data against your registry using exact and approximate matching, populate the errors object with field-level messages, and call complete().

How This Demo Works

  1. Click Fill Sample Data to load a near-match example (Jon Smith with DOB 1987-04-12), or enter values manually.
  2. When you click Register Participant, SurveyJS raises the onServerValidateQuestions event.
  3. The event handler compares the submitted data with an in-demo participant list (with a short delay to simulate an API call).
  4. Exact email or participant ID matches produce duplicate errors. Strong matches based on name, date of birth, and phone number produce possible-duplicate warnings. Messages do not reveal details of existing records.
Try this Expected result after submission
Email john.smith@email.com Duplicate detected (email)
Participant ID EXT-9001 Duplicate detected (participant ID)
Name Jon Smith + DOB 1987-04-12 Possible duplicate
Name Sofia Martinezz + DOB 1985-01-22 Possible duplicate

Connect to an API Endpoint

To check against your CRM, EHR, or study database, call your duplicate-detection endpoint from onServerValidateQuestions. Populate the errors object with the returned messages, then call complete():

function validateDuplicateRecordsAsync(_, { data, errors, complete }) {
  fetch("/api/validation/duplicates", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      fullName: data.fullName,
      dateOfBirth: data.dateOfBirth,
      email: data.email,
      phone: data.phone,
      participantId: data.participantId
    })
  })
    .then((response) => response.json())
    .then((result) => {
      // Example: { errors: { email: "Duplicate detected..." } }
      Object.keys(result.errors || {}).forEach((name) => {
        errors[name] = result.errors[name];
      });
      complete();
    })
    .catch(() => {
      errors["fullName"] = "Duplicate check service is temporarily unavailable. Try again.";
      complete();
    });
}

survey.onServerValidateQuestions.add(validateDuplicateRecordsAsync);

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.