I have a few Text Inputs and TextBoxes and uploadButtons. So I want to verify to not insert empty data into collections. I made all the process manually, with no dataset attached. Only using wixData.insert(). So inputs and the submit button are not binded with anything.
I have the onClick() event where the “product” is created and I want to ABORT the event and send a Error message saying something like “No empty values allowed” or something like that.
By the way onCustomValidation doesn’t work for Empty fields.
Any idea?
1 Like
Are you asking for a simple text field validation?
If so, perhaps something like this should work for you:
export function buttonSubmit_click(event) {
// validate text field 1
let text1 = $w("#text1").text;
if (text1 === "" || text1 === "null" || text1.length < 3) {
// text1 = empty string or null value or less than 3 characters ?
$w("#textStatus").text = "No empty values allowed";
return // exit this function
}
// validation successful
// "create the product here"
// ...
}
You can also set the fields as “Required”: