HI, I would like my required fields to error if they are not entered, just like they do normally when you connect them.
However, as I am using code to submit my data etc, this doesn't work.
I have tried with the below code use the .valid property but it doesn't work at all......
Any advice? Thank you!
export function submitButton_click(event, $w) {
let updates = {
"address": $w("#streetAddress").value,
"unitNumber": $w("#unitNumber").value,
"city": $w("#city").value,
"state": $w("#state").value,
"zipCode": $w("#zipCode").value,
"propertyType": $w("#propertyType").value,
"bedrooms": $w("#bedrooms").value,
"bathrooms": $w("#bathrooms").value,
"squareFootage": $w("#squareFootage").value,
"condition": $w("#propertyCondition").value,
"propertyNotes": $w("#propertyNotes").value,
"name": $w("#name").value,
"emailAddress": $w("#emailAddress").value,
"phoneNumber": $w("#phoneNumber").value
};
let req1 = $w("#propertyType").valid;
let req2 = $w("#bedrooms").valid;
let req3 = $w("#squareFootage").valid;
let req4 = $w("#propertyCondition").valid;
let req5 = $w("#name").valid;
let req6 = $w("#emailAddress").valid;
let req7 = $w("#phoneNumber").valid;
let req8 = $w("#bathrooms").valid;
if (req1 === 'false' || req2 === 'false' || req3 === 'false' || req4 === 'false' || req5 === 'false' || req6 === 'false' || req7 === 'false' || req8 === 'false') {$w("#errorText".show);}
else
{wixData.save("Sellers", updates)
.then(() => {
sendFormData();
//go to sellers page
wixLocation.to("/sellers-3");
})
.catch( (err) => {
console.log(err);
} );
}}
Have you tried if (req1 === false without the quotes? Boolean is never a string, it is a boolean, true or false