Validator Function is not working as expected
I have used a validor to check textfields text are empty or not and if not empty then i am executing a service because validator will return TRUE otherwise i show message with status message FUNCTION to show that please enter the text into fields but it is not working. if i normally write output= true or false then only it works. can anyone please guide me in this regard. I have put a screenshot of bindings and my parameters also please have a look into it. I am using Thingworx 9.3


let Output = true; // Initialize Output as true
// The isValid function should accept a single parameter to check.
const isValid = (param) => {
return param !== null && param!=="" && param.trim() !== '';
};
try{
// Check each parameter individually
if (!isValid(emailAddress)) {
console.log('Invalid email address');
Output = false;
}
if (!isValid(firstName)) {
console.log('Invalid first name');
Output = false;
}
if (!isValid(lastName)) {
console.log('Invalid last name');
Output = false; // Change from return false to setting Output to false
}
if (!isValid(loginName)) {
console.log('Invalid login name');
Output = false;
}
if (!isValid(loginPassword)) {
console.log('Invalid login password');
Output = false;
} } catch (error) {
console.log('Error occurred: ' + error.message);
Output = false;
}
console.log("Output: " + Output);

