Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

Mark Solution

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

SOLVED

Multifield max validation is still adding fields after max limit reach

Avatar

Level 2

Hi,

 

I have added max limit 5 for multifield dialog validation but after reaching the message it is showing red border around the dialog but fields still can be added. 

 

Please find the below code snippet for dialog validation:

 

 

(function ($, window, document) {
$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
// check elements that has attribute data-foundation-validation with value starting with "multifield-max"
selector: "[data-foundation-validation^='max']",
validate: function (el) {
debugger;
// parse the max number from the attribute value, the value maybe something like "multifield-max-6"
var validationName = el.getAttribute("data-validation")
var max = validationName.replace("max-", "");
max = parseInt(max);
var ui = $(window).adaptTo("foundation-ui");
// el here is a coral-multifield element
if (el.items.length > max) {
return "Max allowed items is "+ max
}
}
});
})
($, window, document);

 

 

Screenshot (198).png

The validation message is there but still i can add items. 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
1 Reply

Avatar

Correct answer by
Community Advisor

Please check below article for min max validation

http://myaemlearnings.blogspot.com/2018/03/custom-validation-for-coral-ui-3.html?m=1

Arun Patidar

AEM LinksLinkedIn