Skip to main content

Notifications

Announcements

No record found.

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?

  • necsa Profile Picture
    necsa 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

  • ghassanm Profile Picture
    ghassanm 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
    cloflyMao 25,198 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans