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,...
Unanswered

Zipcode Validation in CE

(0) ShareShare
ReportReport
Posted on by 375

How to achieve Zipcode validation?

Any simple, easy to use solution for this except third part tool?

Have anyone implemented such thing like an entity and in that Country and Zipcode combination is there and using that it validated?

Anything like this?

Let me know if anyone has implemented such a thing, Let me know the solution and what needs to be taken care for the same?

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Milan,

    You can validate zipcode by using JavaScript.

    Here are steps.

    1.write js code(eg. Country is US or CA). If you want to validate other country zipcode, you can add manually according example.

    function checkZipcode()
    {
        var zipCode = Xrm.Page.getAttribute("address1_postalcode").getValue();
        var country = Xrm.Page.getAttribute("address1_country").getValue();
        switch (country) {
            case "U.S.":
                isValidZip = /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/;
                break;
            case "CA":
                isValidZip = /^([A-Z][0-9][A-Z])\s*([0-9][A-Z][0-9])$/;
                break;
            default:
                isValidZip = /^(?:[A-Z0-9] ([- ]?[A-Z0-9] )*)?$/;
        }
          if(zipCode != null)
            {           
            if(isValidZip.test(zipCode))
            {
                alert("zip valid"); 
            }
            else
            {
                alert("zip invalid");
                Xrm.Page.getAttribute("address1_postalcode").setValue(null);
            }
           }
    }
    

    2. Add your JavaScript code in a Script web resource.

    2555.png

    3. Associate Script web resource to a form.

    4812.png

    4.Test

    (1) you zipcode is right.

    187263.png

    (2) your zipcode is wrong.

    7271.png

    Regards,

    Clofly

  • CU30082022-0 Profile Picture
    90 on at

    Hi Milan,

    did you get a good solution for Zip code Validation for D365 CRM?

  • necsa Profile Picture
    3,455 on at

    There is no OOB functionality in Dynamics CRM. But you can use different API to validate your address or Zip Code. Take as reference following links:

    www.address-validator.net/api.html

    community.dynamics.com/.../854455

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 165

#2
ManoVerse Profile Picture

ManoVerse 134 Super User 2026 Season 1

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 59 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans