AEM6.5 Adaptative form Dynamic validation on text field for guidefield component based on selection values | Community
Skip to main content
New Participant
March 21, 2023

AEM6.5 Adaptative form Dynamic validation on text field for guidefield component based on selection values

  • March 21, 2023
  • 1 reply
  • 692 views

Hello,

 

I need to add Dynamic validation to /libs/fd/af/components/guidefield component.

 

It is dynamic because  for each selection value, I select there must be unique validation applied to guidefield component based on user input value to the field.

 

For example

 

Selection 1:   

A>guidefield  validation must be regex applied must be  AXXX-XXX4

B>The error displayed must be please enter in the format AXXX-XXX4

Selection 2  :

a>guidefield  validation must be regex applied must be  BXXX-XXXX-XXX9

B>The error displayed must be please enter in the format BXXX-XXXX-XXX9

 

could you please provide  inputs as how this could be  implemented and how to apply dynamic error messages.

 

Regards,

Srinivas

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Vijay_Katoch
New Participant
March 21, 2023

You need to use the switch block, something like below to achieve this,

 

let regexp, message;
switch (yourFormatType) {
case 'format1':
regexp = Format1_REGEXP;
message = 'The input is not a valid Format1';
break;
 
case 'format2':
default:
regexp = Format2_REGEXP;
message = 'The input is not a valid Format2';
break;
}

 

New Participant
March 21, 2023

Thanks for the input.

 

My concern i am not able to Suppress default Validation error message in AEM

 

I would want to insert a error msg like 

 please enter in the format AXXX-XXX4, instead of OOTB msg "there is a validation error in the field" and also this will change for each selection.

 

How to achieve it 

 

Regards,

Srinivas