User input to reference existing database

Hi,

I have been getting into WIX for work I do however have some issues that I could use some expert help with. We want to start a loyalty program and we have created a database of card numbers and card security codes.
(the security code is 3 characters and the card number is 16 characters long)

I would like to require the card number and security code to match with a card in our database for the user to be able to click the send button.

We made this system so cardholders can apply for e-mails about the program I only want valid cards we produced to match the systems database.

Thanks in advance,

Kind regards,

Caspar

Hi,
You can use query to check whether the card number and security code exists in your database, check out the API here , then, if you get results, you can enable the subscribe button.
Check out this code for example:

wixData.query("myCollection")
  .eq("cardNumber", number)
  .eq("securityCode", code)
  .find()
  .then( (results) => {
    if(results.items.length>0){
        $w("#subButton").enable();
    }
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );

Good luck :slight_smile:
Or

Hi thanks for the response,

I still seem to have some trouble to enable this, we changed the code to 12 digits, the data is used in the following format: 0000 0000 0000 the system sees it as text. How can I make it search the system for an exact card number before being able to submit.

My database title is CardNumber and my send button is called button3, the input button is called cardNumber1.

Thanks in advance,

Kind regards,

Caspar