This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
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
Views
Replies
Total Likes
We are checking with our Touch UI experts to see if there are any examples.
Views
Replies
Total Likes
The reply was:
Hey Scott – not directly but it’d be a mix of
http://experience-aem.blogspot.com/2017/12/aem-63-sample-coral-3-multifield-item-listener.html
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies