Conditional scripts using OnBlur function

The is a general example of how OnBlur can be used to perform an action when a user condition is met.

function TEXT_OnBlur(id, row) 
{ 
    if (id === "text2") 
    { 
        // grab the field data 
        const vCo = lawForm.getFormValue("text2"); 
 
        // check for the 'target' data 
        if (vCo === "2") 
        { 
            portalWnd.cmnDlg.messageBox("you entered company 2"); 
        } 
    } 
    return true; 
} 

In this example, the TEXT_OnBlur function is used to prompt a user when attempting to exit a required field on form PR36.

function TEXT_OnBlur(id, row) 
{ 
    // routine to run function is specific field 
    return (id === "text3" ? isPayCodeEntered(row) : true); 
} 
 
async function isPayCodeEntered(row) 
{ 
    // check the value of the field, if emtpy go further 
    if (lawForm.getFormValue("text3", row) !== "") 
    { 
        return true; 
    } 
 
    // give alert and position the cursor in the required field 
    lawForm.setMessage("Pay Code is Required"); 
    await portalWnd.cmnDlg.messageBox("Pay Code is Required"); 
    lawForm.positionInFieldById("text3"); 
    return false; 
}