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,...
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)
  • necsa Profile Picture
    3,455 on at
    RE: Zipcode Validation in CE

    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

  • CU30082022-0 Profile Picture
    90 on at
    RE: Zipcode Validation in CE

    Hi Milan,

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

  • cloflyMao Profile Picture
    25,208 on at
    RE: Zipcode Validation in CE

    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

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 141

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 132

#3
DAnny3211 Profile Picture

DAnny3211 130

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans