AD B2C - Customize Required field message for each field

1.1k Views Asked by At

I am trying to change the error message of the required field, as of now it is showing common error message for all the fields.

But I would like to have different message for each field.

I have tried with localizations, but unable to set the configuration for each field. The one below set the same message for all the fields.

<LocalizedString ElementType="UxElement" StringId="required_field">Value is required.</LocalizedString>

Can you please suggest a way to handle this scenario in the AD B2C custom policy?

Or is there anything I can do with jQuery in the Custom HTML templates to change the error message?

enter image description here

2

There are 2 best solutions below

0
On

You need to upgrade pagelayout(DataUri) version to latest version.

<ContentDefinition Id="api.localaccountsignup">
  <LoadUri>https://example.com/selfAsserted.html</LoadUri>
  <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
  <DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.26</DataUri>
  <Metadata>
    <Item Key="DisplayName">Local account sign up page</Item>
  </Metadata>
</ContentDefinition>

Then required_field_descriptive can be used for localisation.

0
On

https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization-string-ids#sign-up-and-self-asserted-pages-example

 <LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfMissingRequiredElement">Missing required element: {0}</LocalizedString>

{0} will dynamically use the claim display name.

"error_requiredFieldMissing” can be used in addition.