Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

required property for alt text in image component does not work

Avatar

Level 1

Hi 

 

AEM 6.3

 

I have set "Alternative Text" under Accessibility tab of image component to mandatory (required true).

 

On form submission field gets highlighted but form submission continues.

 

Any help to fix this? i want to make Alt text field mandatory for image component.

 

image supertype: /wcm/foundation/components/image

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

It should work, it could be a bug.

Anyways top of that you can add a extraclientlibs to validate img alt and stop dialog submit.

 

(function ($, $document) {
    "use strict";
    
    $(document).on("click", ".cq-dialog-submit", function (e) {
var $inputEle = $('[name="./alt"]');
if($inputEle !== null || typeof $inputEle !== "undefined")
{
var altValue = $inputEle.find("input.coral-Textfield").val();
if(altValue === "")
return false;
}
  }
});

 



Arun Patidar

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

It should work, it could be a bug.

Anyways top of that you can add a extraclientlibs to validate img alt and stop dialog submit.

 

(function ($, $document) {
    "use strict";
    
    $(document).on("click", ".cq-dialog-submit", function (e) {
var $inputEle = $('[name="./alt"]');
if($inputEle !== null || typeof $inputEle !== "undefined")
{
var altValue = $inputEle.find("input.coral-Textfield").val();
if(altValue === "")
return false;
}
  }
});

 



Arun Patidar

Avatar

Level 1

Thanks Arun. Unfortunately, this code is not working.

 

tried to trace the control for my script but control is not coming over here

 

anilm50076901_0-1583870599826.png

 

Avatar

Community Advisor

you need to add this clientlib in the component dialog as extraclientlibs property

https://experienceleaguecommunities.adobe.com/t5/Adobe-Experience-Manager/Touch-UI-cq-auhoring-dialo...

 

Please check logic as well, I have just written to give you an idea to handle custom validations.



Arun Patidar