web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 94
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
    TFN Validation in Contact Form
    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
    TFN Validation in Contact Form
    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
    TFN Validation in Contact Form
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 152 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 103

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 74

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans