Top

Validation failure:

With form validation, Whatfix ensures that user input is validated against criteria and if the input is not found compliant, then an error message is displayed. For example, if there is an incorrect entry on a form that is being validated, and the user tries to submit the form, then the user is displayed a warning. If there's a step that is particularly important to complete correctly, when there is a failure, the branch feature can be used to redirect the user to the failed step 3 by showing the step again.   

Given below is an example of a script that checks if the user input is numeric or not. If the input is not numeric, then an error message that says "Input Error" is displayed. If the entry is numeric, the validation is passed and the procedure is not interrupted.

The flow ID for a walkthrough can be seen when you navigate to a particular walkthrough on your dashboard. It is the alpha-numeric part at the end of the URL. 

Modify the snippet as per your validation requirement and include it in your integration script section after adding the flow_id and the desired step number.  In the example below, the flow id is b1ee62d0-791e-11e8-a73c-1c1b0dcac017 and the step to be validated is step number 1.

function isNumber(inputNumber) {
    return !isNaN(inputNumber);
}

function isAlpha(inputText) {
    //logic to evaluate
    return false;
}

function onValidate(event) {
    var result = {
        isValid: true,
        error: "Input Error"
    };
    if (event.flow_id == "b1ee62d0-791e-11e8-a73c-1c1b0dcac017" && event.step == 1) {
        result.isValid = isNumber(event.input);
        return result;
    } else {
        return null;
    }
}

_wfx_settings.onValidate = onValidate;

For additional configurations, see Smart Tip configuration.