How to limit access to a form?

How to limit access to a form?

Roger_vita
Tourist
9 1 0

Hello, I would like to know if there is a way to limit access to a form after it has been submitted by a certain number of people, to stop accepting submissions or automatically block access to the page.

I am going to create a discount and I only have 20 coupons, but 50 people have entered and signed up on the form. Therefore, I want to limit it to only the first 20.

Replies 4 (4)

rajimulislamjoy
Shopify Partner
419 41 73

@Roger_vita  Hey To limit form submissions, use an app like Mechanic or Custom Forms that supports submission limits. Set it to cap at 20 entries, after which the form will auto-close or redirect users. This will help control coupon availability

Please don't forget to Like & Mark Solution to the post that helped you. Thanks!
If you'd like to support me, you can Buy Me a Coffee
Need a Shopify Designer or Dropshipping Expert ?
Hire us at WhatsApp! For Shopify Design | Shopify Customize | Dropshipping

mudasir_qayyum
Tourist
13 0 1

To limit form access after a certain number of submissions, you can use custom code or third-party form builders like Typeform or JotForm, which allow setting submission limits; configure the form to close automatically once 20 people have submitted, or use conditional redirects to a “Closed” page once the limit is reached.

Roger_vita
Tourist
9 1 0

Could you help me with the custom code? I don’t understand much about programming.

DaisyVo
Shopify Partner
4275 468 561

Hi @Roger_vita 

Yes, you can limit form submissions to only a certain number of people. Here are some ways to do it, depending on the platform you're using for your form:

1. Using Google Forms with a Script (Advanced)

Google Forms doesn’t natively support limiting responses, but you can add a custom script to close the form after a set number of responses. Here’s how:

  • Create your form in Google Forms.
  • In Google Sheets, link your form by clicking on Responses > View in Sheets.

In the Google Sheets file, click Extensions > Apps Script and paste the following code:

function limitResponses() {

  const maxResponses = 20; // Set the maximum number of responses

  const form = FormApp.openById("YOUR_FORM_ID"); // Replace YOUR_FORM_ID with your form's ID

  const responses = form.getResponses().length;

  if (responses >= maxResponses) {

    form.setAcceptingResponses(false);

  }

}

  •  
  • Replace YOUR_FORM_ID with the unique ID from your Google Form URL.
  • Set a trigger to run this function periodically (like every minute) under Triggers in the Apps Script dashboard.

This script will automatically close the form once it reaches 20 responses.

2. Using a Form Builder with Built-in Limits

Many form builders have built-in settings for limiting the number of submissions. Here are a few that support this feature:

  • JotForm: Allows you to set a maximum number of submissions and can automatically disable the form once that limit is reached.
  • Typeform: You can set response limits in the settings to automatically close the form after a certain number of submissions.
  • Wufoo: Provides options to limit submissions and display a custom message once the limit is reached.

In each of these tools, you'll typically find an option in the settings under Limits or Response Limits.

3. Custom Code on Your Website

If you're embedding a form on your website and you have coding experience (or a developer’s help), you can add JavaScript to count the number of submissions and disable the form when the limit is reached.

Here’s a basic outline:

  • Use JavaScript or PHP to store the submission count in a database or a file.
  • Check the count each time someone tries to submit the form.
  • If the count is 20 or above, hide or disable the form and display a message that the limit has been reached.

This approach can give you complete control, but it requires technical setup.

4. Using Zapier or Integromat with Google Sheets

If you’re not comfortable with scripts, you can use an automation tool like Zapier or Integromat to manage form responses:

  • Send each form submission to a Google Sheet.
  • Create an automation that monitors the number of rows.
  • Once the sheet has 20 rows, the automation can disable the form or send a notification to manually close it.

Summary

If you need an easy-to-implement solution, using a form builder like JotForm or Typeform would be the quickest way. If you’re using Google Forms, the script method above will work well but may require a bit more setup.

Let me know if you’d like further help with any specific tool!

Best regards,

Daisy

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution