Make a buttton clickable once per day per user.

I have a button that submit a form and i would like users to submit the info only once in a day. Can anyone suggest to me a regex for that? i will appreciate.

Hi,
How about adding a field to the member’s database collection that saves new Date ( method ).
Every time you enter the page it enable s/ disable s the button according to the Date (if past more then 24h).
Roi.

hello, how do you do that ?I have the dataset as #dataset3
export function button15_click(event, $w) { { var sum = 50
if ($w(‘#input8’).value)
sum +=50+ parseInt( $w(‘#input8’).value);{
$w(“#input8”).value = sum; $w(“#dataset3”).setFieldValue(“accountB”, sum);

    }} 

//Add your code for this event here:
}

Hi,
I don’t understand your code.
Assuming that the button in a dynamic item page
The structure should be like this:

import wixData from 'wix-data';
$w.onReady(() => {
  $w('#yourDataset').onReady(() => {
    const currentItem = $w('#yourDataset').getCurrentItem():
    if (currentItem.lastPressed > '24H') { // pseudo code... use Date method. read more on the link.
      $w('#yourButton').enable();
    } else {
      $w('#yourButton').disable();
    }
  });
});

function buttonClick() {
  const someDateFormat = new Date(); // pseudo code...
  $w('#yourDataset').setFieldValue("lastPressed", someDateFormat);
}

Good luck!
Roi.

THANKS YOU SO MUCH Roy. You have saved my day. Can i have the button enabled on a new date?

And the above code has disabled all the buttons connect to the dataset. How can i enable only the selected button.

Hi,
You need to develop the code above, it is a sample.
Roi.

I have created the code and it has worked well but it has disabled all buttons connected to the database.

Please paste the code here.

import wixData from ‘wix-data’;
$w.onReady(() => {
$w(‘#dataset3’).onReady(() => {
const currentItem = $w(‘#dataset3’).getCurrentItem();
if (currentItem.lastPressed > ‘24H’) { // pseudo code… use Date method. read more on the link.
$w(‘#button17’).enable();
} else {
$w(‘#button17’).disable();
}
});
});

function button17_click() {
const someDateFormat = new Date(); // pseudo code…
$w(‘#dataset3’).setFieldValue(“lastPressed”, someDateFormat);
}

Hi,
It’s the same code I gave you before.
You need to keep on developing it. it’s not suppose to work as is.
Roi.

Thank you. Have found a way to work about it.

I tried this and it worked great, however…
This disables the button for all users. how do i only disable the button for the user.
Meaning, 1 click per user per day?
thanks
Matt