Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

Validations inside Multifield Touch UI

Avatar

Former Community Member

Hello All,

I have a requirement to validate the value authored in a textfield inside a multifield. I am using ACS Commons multifield (multifield & multifieldpanel) to create the touch UI dialog.

I tried using two approaches :-

registry.register("foundation.validation.validator", {

        selector: "[data-validation=font-color-multifield]",

        validate: function(el) {

    var field = el.closest(".coral-Multifield");

        var fontColorField = field.getElementsByClassName("fontColor");

        $.each(fontColorField , function(i , element) {

    var value = element.value;

            if (!/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/.test(value) && value != '') {

                element.classList.add("is-invalid");

          return false;

            }else {

element.classList.remove("is-invalid");

            }

});

----------------------------------------------------------------------------------------------------------

$(document).on("dialog-ready", function (e) {

$(".cq-dialog-submit").click(function() {

        //var field = $(this).parent();

        var field = $(this).closest("form.foundation-form");

            var fontColorField = field.find("[name='./linkColor']");

            $.each(fontColorField , function(i , element) {

                var value = element.value;

                if (!/(^#[0-9A-Fa-f]{6}$)|(^#[0-9A-Fa-f]{3}$)/.test(value) && value != '') {

                    element.classList.add("is-invalid");

                    var ui = $(window).adaptTo("foundation-ui");

                    ui.alert('The field must be in the format: "#xxxxxx" or "#xxx"');

                return false;

                }else {

                    element.classList.remove("is-invalid");

                    return true;

                }

            });

    });

    });

However in both cases the dialog gets submitted in-spite of the wrong value authored in the textfield. Any help will be highly appreciated.

Note: This works perfectly fine in a simple textfield outside a multifield.

Thanks in Advance
Ashish Ranjan

3 Replies

Avatar

Level 10

We are checking with our Touch UI experts to see if there are any examples.

Avatar

Level 10

Avatar

Former Community Member

Hello Sir,

I also have the min and max limit added to the multifield , it works like a charm. However the issue is on dialog-submit event. If you look at the 2nd approach I have written an alert pop-up which given an alert but the dialog still closes. I am trying to catch hold of event to stop that.

Kindly let me know if anymore details is needed from my end and thank you for your help.

Thanks & Regards
Ashish Ranjan