Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Validate

  • Last UpdatedJun 25, 2024
  • 1 minute read

Use scripts for the Validate property to validate custom validations for a control.

Validations are triggered only when a form is submitted and the submission of the form fails even if one validation fails.

To validate custom validations for a control

  • Code the script as follows for the Validate property of a control:

Task

Script

  • Validate custom validations for the control.

return new ValidationOptions(true, "");

  • Show an error message when custom validations for the control fails.

return new ValidationOptions(false, "Error Message");

To validate custom validations for a control based on the value of another control

You can validate custom validations for a control based on the value of another control.

Example

If you want to enforce entering a value for the Comments (T1) control as per the selection in the Action (D1) control, then you can code the script for the Validate property of the Comments (T1) control as follows:

if(control.findById("D1").value !== "1")

{

if (control.findById("T1").value === "")

{

return new ValidationOptions(false, "Enter your comments.");

}

else

{

return new ValidationOptions(true, "");

}

}

else

{

return new ValidationOptions(true, "");

}

If you want to enforce entering a value for the Password (P1) control with at least eight characters containing at least a number, a lowercase letter, and an uppercase letter, then you can code the script for the Validate property of the Password (P1) control as follows:

var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/;

if( re.test(currentValue) === false)

{

return new ValidationOptions(false, "Password must have at least eight characters  and contain a number, a lowercase letter, and an uppercase letter.");

}

else

{

return new ValidationOptions(true, "");

}

TitleResults for “How to create a CRG?”Also Available in