Preview:
// DMP Tools Form

def cfName = getFieldByName("Communication Email")
cfName.clearError()
String cfNameValue = cfName.getValue()

// Only proceed if the field has a non-empty value
if (cfNameValue && cfNameValue instanceof String && cfNameValue.trim()) {
    // Check if the value ends with the required domains
    if (cfNameValue.endsWith("@acme.com") || cfNameValue.endsWith("@acmeTeam.com")) {
        return // No error if the value matches the required domains
    } else {
        // Set error if the conditions are not met
        cfName.setError("The email should end with @acme.com or @acmeTeam.com")
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter