I have component with dropdown select and a multifield so based on dropdown select value user should add selected number of multifield items, Js is working fine but when dropdown value is 2 and when we click on add button it is displaying restrict message initially but it should display when more that 2 multifield items are added. Anyone can suggest the solution. My js logic:
(function ($, Sdocument, gAuthor) {
var COUNT_SELECT = ". /variation";
var maxCount;
$document.on("dialog-ready", addSelectlistener);
function (addSelectlistener){
var Scountselect = $("coral-select [name=‘" + COUNT_ SELECT + "’]");
var countSelect = $countSelect[0];
var countNumber = countSelect._initialValues[0];
if (countNumber == “4xs” ) {
countNumber = “4”;
}
maxCount = parseInt(countNumber);
countSelect.on ("change", adjustMultifieldItems) ;
}
function adjustMultifieldItems (event){
var countSelect - event. target;
var checkCount = countSelect.value;
if (checkCount ==‘4xs’){
checkCount=‘4'
}
maxCount=parseInt (checkCount);
}
$.validator.register("foundation.validation validator",{
selector: 'coral-multifield',
validate: function (el) {
var totalPanels - el["0"]. items. getAll(). length;
if(totalPanels !- maxCount) {
return "Please add
"+maxCount+ " items;
}
}});
}(jQuery, jQuery (document), Granite.author));