On the paste page form shown below, I need to restrict the input to prevent capital letters. We have something similar on our form for creating new pages, but this doesn't seem to be working when I include a selector for the name field on the paste form.
This is the form where I need to prevent capital letters:
This code prevents capital letters on new pages:
var pageNamePattern = /^[a-z0-9_\-,]+$/; // remove A-Z from this regex so that authors cannot use upper-cased characters
$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
selector: '[data-foundation-validation~="admin.pagename"]',
validate: function(el) {
var valid = pageNamePattern.test(el.value) || el.value === "";
if (!valid) {
return Granite.I18n.get("mycompany.validation.page_name_regex");
}
}
});
The field name on the paste form does not have a `data-foundation-validation` value, so I'm using the selector `#pastePageDialog input` for a test. When I try this, the validation does not stop me from entering capital letters.
Solved! Go to Solution.
Views
Replies
Total Likes
hi @jeremyc82321732 ,
Please check this out AEM: Dialog Field Validations (aemhub.blogspot.com)
Hoping this helps.
Thanks,
Nikita Garg
hi @jeremyc82321732 ,
Your validation might be overriden by OOTB validation on name field. On the name field, i checked this JS is getting applied. So, you can debug and check.
Thanks,
Nikita Garg
No matter what I try, the selector I was using is not getting caught. Instead of changing the selector on this function (which works on other instances), is there a way to add the attribute `data-foundation-validation="admin.pagename"` to the name field on the paste form? This way I do not need to alternate a JavaScript that is already working.
hi @jeremyc82321732 ,
Please check this out AEM: Dialog Field Validations (aemhub.blogspot.com)
Hoping this helps.
Thanks,
Nikita Garg
Views
Likes
Replies
Views
Like
Replies