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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

data validation by certain number of digits

(0) ShareShare
ReportReport
Posted on by

I need to create a numerical field with 13 characters long. But need validation so that users cannot incorrectly add any number that is too long or too short.  is there any OOTB validation we can added with this field? 

Thanks!

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi Ivy,

    you need to write the simple javascript without that it is not possible OOB.

    function Validation(executionContext) {
        var formContext = executionContext.getFormContext();
        var test = formContext.getAttribute("new_test1").getValue();
        var control = formContext.getControl("new_test1");
        if (test !== "") {
            if (isNaN(test)) {
                control.setNotification("Please enter only numbers", "CHKNUM");
            }
            else if (test.length != 13) {
                control.setNotification("Please enter only 13 characters", "CHKNUM");
            }
            else{
                control.clearNotification("CHKNUM");
            }
        }
    }

    You can refer following link to add the JS to form.

    https://reenhanced.com/2019/how-to-get-started-with-form-scripts-in-dynamics-365/

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    Fubar Profile Picture
    2,761 on at

    You could also achieve the same by using an existing PCF Control 'input mask' on the form attribute (i.e. without JavaScript)

    docs.microsoft.com/.../additional-controls-for-dynamics-365-for-phones-and-tablets

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans