Display Error message

Hi, I wanted to create a code wherein If I put an invalid Identification code an error message will display. As of the moment what I had created was if the user did not put any string(null) in the textbox(field) it will display a message and when the user will insert the correct Identification code the table from the Database will show. I’m thinking if I’m going to use two if else statement. Need help. Thanks!

Here’s my code:

import wixData from ‘wix-data’;

//For full API documentation, including code examples visit Velo API Reference - Wix.com

$w.onReady(function () {

//TODO: import wixData from 'wix-data'; 

});

export function verify1_click(event, $w) {

$w("#input1").onCustomValidation((value, reject) => { 

    if (value.length === 0) { 

        reject("Please enter Certificate Identification Code"); 
    //  $w("#text140").text = "Please enter Certificate Identification Code"; 
        $w("#text140").show(); 

    } else 
        $w("#text140").hide(); 
    wixData.query('SwissITStudents') 
        .eq("title", value) 
        .find() 
        .then(res => { 

            console.log(res); 

            $w('#table1').rows = res.items; 

        }) 
    .catch((err) => { 
        let errorMsg = err;        
        
    }); 
    const alert = $w('#text140').hide();   

}) 

}

I think this example would help you.

Thanks, I will check the forwarded link.

@ahmdjsalhi There’s nothing at the link you sent. maybe it moved?

Ratings Input and Display

Let visitors rate recipes and display the rating results.

Ratings by User

Let logged-in users rate recipes and edit their ratings.