question

arunvijayakumar avatar image
0 Votes"
arunvijayakumar asked TyroneSmith-5982 published

Azure B2C custom attribute fixed length

Hello,

         Does anyone know how to add a fixed length validation for a custom attribute to Azure B2C signup/signin template.

Im trying to figure how to restrict user to enter just 10 digit.

For example, user attribute (Telephone Number) = Restrict to integer and only 10 digit.

Any comments or advice is truly appreciated.

azure-ad-b2c
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered JamesTran-MSFT commented

Hi @arunvijayakumar · Thank you for reaching out.

This is possible only by using Custom Policy in B2C and not with User flows. In the TrustFrameworkBase.xml file, define the attribute under claims schema with Restriction parameter containing regex as mentioned below:

<ClaimType Id="extension_phone">
        <DisplayName>Type your phone number</DisplayName>
        <DataType>int</DataType>
        <UserInputType>TextBox</UserInputType>
    <Restriction>
          <Pattern RegularExpression="^[0-9]{10}$" />
        </Restriction>
</ClaimType>

Also, make sure you extend Azure AD schema of the B2C tenant with the above custom attribute using the steps I have shared in below thread to get it working:
https://docs.microsoft.com/en-us/answers/questions/60338/b2c-extension-property-creation-error-using-graph.html


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @arunvijayakumar · Just checking if you had a chance to test it out.

0 Votes 0 ·

@arunvijayakumar
I just wanted to check in and see if you had any other questions or if you were able to resolve this issue?

If you have any other questions, please let me know.
Thank you for your time and patience throughout this issue.


Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

0 Votes 0 ·
TyroneSmith-5982 avatar image
0 Votes"
TyroneSmith-5982 answered TyroneSmith-5982 published

Morning @amanpreetsingh-msft ,

Are we able to alter the text input to use maxlength attribute?
Also are we able to change the input type to number?

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.