Expand my Community achievements bar.

Elevate your expertise and be recognized as a true influencer! Nominations for the exclusive Adobe Community Advisor program 2023 are now OPEN.

Validate the name field on paste


Level 2

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.

Any ideas?

3 Replies



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.




Nikita Garg


Level 2

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.