# How can I allow users to only submit a form once?

**URL:** <https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546>\
**Category:** Get Help\
**Tags:** form\
**Created:** [July 12, 2023, 6:47pm UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546 "2023-07-12T18:47:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaberlem](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@aaberlem](https://community.fliplet.com/u/aaberlem)\
**Post date:** [July 12, 2023, 6:47pm UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/1 "2023-07-12T18:47:08Z")

</div>

Hi,  
Is it possible to allow users to only submit a form once? To restrict them from submitting the form again and again.

---

<div class="post-metadata">

**Author:** ![Deb](https://dub1.discourse-cdn.com/flex017/user_avatar/community.fliplet.com/deb/32/159_2.png) [@Deb](https://community.fliplet.com/u/Deb)\
**Post date:** [July 13, 2023, 7:16am UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/2 "2023-07-13T07:16:41Z")

</div>

Hi Alex,

You will need to use custom code to achieve this, which you can access using the Developer options \> Javascript.

The general idea is the following:

In the form they are submitting add a Email field, you can set this to be hidden. This will store the Email in the Data Source.  
Use a form hook to check if they have already submitted it and reject the promise from submitting the form again.  
Example JS:

```js
Fliplet.Hooks.on("beforeFormSubmit", function (data) {
  //change the DS id below to the data source where the entries are stored.
  return Fliplet.DataSources.connect(123)
    .then(function (connection) {
      return connection.findOne({
        where: {
          Email: data.Email
        },
      });
    })
    .then(function (record) {
      if (record) {
        return Promise.reject("You have already submitted the form");
      }
    });
});

```

Let me know if you need anything else.

Thanks,  
Deb

---

<div class="post-metadata">

**Author:** ![salteduckegg](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@salteduckegg](https://community.fliplet.com/u/salteduckegg)\
**Post date:** [October 25, 2024, 3:16am UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/3 "2024-10-25T03:16:12Z")

</div>

Hai. it doesn’t work for me

did i miss something?

 ![Screen Shot 2024-10-25 at 10.14.55](https://europe1.discourse-cdn.com/flex017/uploads/fliplet/original/1X/f4c2a5d9caf93727399aef521ab4976404593076.png)

---

<div class="post-metadata">

**Author:** ![thekellisfam](https://dub1.discourse-cdn.com/flex017/user_avatar/community.fliplet.com/thekellisfam/32/263_2.png) [@thekellisfam](https://community.fliplet.com/u/thekellisfam)\
**Post date:** [November 6, 2024, 5:37am UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/4 "2024-11-06T05:37:38Z")

</div>

Please send more screenshots and details so we can try to help better

---

<div class="post-metadata">

**Author:** ![salteduckegg](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@salteduckegg](https://community.fliplet.com/u/salteduckegg)\
**Post date:** [November 25, 2024, 1:55am UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/5 "2024-11-25T01:55:50Z")

</div>

i used the add screen form

 ![Screen Shot 2024-11-24 at 22.06.02](https://europe1.discourse-cdn.com/flex017/uploads/fliplet/original/1X/af1cc9677ebd00352c82f50d49eefddd1de777d9.png)  
 ![Screen Shot 2024-11-24 at 22.06.22](https://europe1.discourse-cdn.com/flex017/uploads/fliplet/original/1X/206cd663688c9ab8533a0735aecc8aeb7e650715.png)  
 ![Screen Shot 2024-11-25 at 08.53.59](https://europe1.discourse-cdn.com/flex017/uploads/fliplet/original/1X/c53c4a84e7a3e5efaaef2d4da4ce3325e3e7f545.png)

---

<div class="post-metadata">

**Author:** ![Deb](https://dub1.discourse-cdn.com/flex017/user_avatar/community.fliplet.com/deb/32/159_2.png) [@Deb](https://community.fliplet.com/u/Deb)\
**Post date:** [November 27, 2024, 8:59am UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/6 "2024-11-27T08:59:41Z")

</div>

Hi,

Looks like you are missing some quotes around the string “Screen template - Get in touch” and also if you use the name of the datasource instead of an id you have to use a different JS API. Try this:

```js
Fliplet.Hooks.on("beforeFormSubmit", function (data) {
  //change the DS name below to the data source where the entries are stored.
  return Fliplet.DataSources.connectByName("Screen template - Get in touch")
    .then(function (connection) {
      return connection.findOne({
        where: {
          Email: data.Email
        },
      });
    })
    .then(function (record) {
      if (record) {
        return Promise.reject("You have already submitted the form");
      }
    });
});

```

---

<div class="post-metadata">

**Author:** ![salteduckegg](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@salteduckegg](https://community.fliplet.com/u/salteduckegg)\
**Post date:** [November 28, 2024, 12:47pm UTC](https://community.fliplet.com/t/how-can-i-allow-users-to-only-submit-a-form-once/546/7 "2024-11-28T12:47:46Z")

</div>

It works. thank you
