How to extend Umbraco Forms validation

With jQuery validate I added a custom validator for my package (intl-tel-input).

How can I add a custom validator to the native Umbraco Forms validation?

I guess I would need to convert it to use this library?

Something along these lines.

; (function () {
    // Exposes window['aspnetValidation']
    let v = new aspnetValidation.ValidationService();
    // Register a custom validator for validatephonenumber

    v.addProvider("validatephonenumber", function (value, element, params) {
        const fieldValue = value;
        const otherFieldName = params.other;
        const comparisonType = params.type;
        let returnValue = false;

        {....}

        // return result
        return returnValue;
    });
    v.bootstrap();
})();
1 Like

Perfect thanks, I will take a look soon

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.