Hi All,
I need to restrict author to put different name in given text field the value that they are authoring, it should be same. example:
We have 2 tabs : Name and Category. having textfield in it.
Now Author Should enter same values, means the value of Category should be same as Name or vice-versa. otherwise dialog will not save and shows error: value should be same.
I am trying to use Validator framework. and since it is component level validation I have created clientlibs under component, and provided clientlib category to component dialog using extraClientlibs : [categoryname].
Can anyone suggest me how to handle the validation of two fields.
validation =name-validation for Name tab and
validation =category-validation for Category tab
(function($, Coral) {
"use strict";
var registry = $(window).adaptTo("foundation-registry");
registry.register("foundation.validation.validator", {
selector: "[data-validation=name-validation]",
validate: function(element) {
//
}
});
})(jQuery, Coral);
or is there any other better way to do this task
Thanks.
@arunpatidar @kautuk_sahni @BrianKasingli @krati_garg @aanchal-sikka
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
@tushaar_srivastava Try below code snippet and change names accordingly, I have used category and title as files names. Shouls be same as name property value in dialog field.
(function($, Coral) {
"use strict";
var registry = $(window).adaptTo("foundation-registry");
registry.register("foundation.validation.validator", {
selector: "[name='./category']",
validate: function(element) {
let title = $("[name='./title']").val();
if(title !== element.value) {
return "Value is not same as Title";
}
return;
}
});
})(jQuery, Coral);
@tushaar_srivastava Try below code snippet and change names accordingly, I have used category and title as files names. Shouls be same as name property value in dialog field.
(function($, Coral) {
"use strict";
var registry = $(window).adaptTo("foundation-registry");
registry.register("foundation.validation.validator", {
selector: "[name='./category']",
validate: function(element) {
let title = $("[name='./title']").val();
if(title !== element.value) {
return "Value is not same as Title";
}
return;
}
});
})(jQuery, Coral);
Thank you @Anudeep_Garnepudi , this worked and I was making code more complex by registring two different validators. and trying to pass as Array.
This really helped.
Views
Likes
Replies