web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

TFN Validation in Contact Form

(1) ShareShare
ReportReport
Posted on by 96
Hi All,

Is there a way to validate the TFN number entered by user on a form(e.g - Contact Form). Like proper validation.
I am new to Dynamics 365 Customer insights, Just working on Trail version.

What I tried:
1. Created a solution in power apps .
2. Included the Contact table.
3. Navigated to Contact forms and included TFN as new form field.
4. Save and publish , the new field appeared on my trial version.

Now I wish to add validation check, Like do we add  any business rule, or an api  or javascript to validate it?

Thank in advance
I have the same question (0)
  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at
    You can write JavaScript which will trigger on change of TFN Number field as shown in below script code:
     
    function onChangeTFN(executionContext) {
        var formContext = executionContext.getFormContext();
        var tfnField = formContext.getAttribute("<yourtfnnumberlogicalname>"); 
        
        if (tfnField) {
            var tfnValue = tfnField.getValue();
            if (!validateTFN(tfnValue)) {
              formContext.getControl("<yourtfnnumberlogicalname>").setNotification("Invalid TFN number", "Error");
            }
        }
    }
    
    
    function validateTFN(tfn) {
    
        var tfnRegex = /^\d{3} ?\d{3} ?\d{3}$/;
    
    
        tfn = tfn.replace(/\s/g, '');
    
    
        return tfnRegex.test(tfn);
    }
    
     
    You can use below link to know more about adding on change event :

    https://carldesouza.com/adding-an-onchange-script-programmatically-in-dynamics-365-power-apps/
     
    Thank You,
    Pradeep Rai.
     
    Please mark ,my response as VERIFIED. if it helps you to resolve the query.
  • Suggested answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Hi partner,
    Maybe you can try to use PCF control if you don't want to use Javascript code.
    There are some existing controls, you can select one as your needs.

    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    Regards,
    Leah
  • Verified answer
    Sohom Rik Profile Picture
    59 on at
    You can use JS webresource that will trigger onchange of the field or onsave 
    For more details refer : https://learn.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/web-resources

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 66 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 45

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans