Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

validation using javascript

(0) ShareShare
ReportReport
Posted on by 826

how to perform validation of email id or any fields using javascript or jQuery ..!!

*This post is locked for comments

  • shil12 Profile Picture
    shil12 30 on at
    RE: validation using javascript

    Hi RamKumarb 

    Kindly go through the provided links below

    www.upgrad.com/.../

    stackoverflow.com/.../how-to-validate-an-email-address-in-javascript

    https://youtu.be/tG4xE9ycgsc

    Hope it helps!

    Regards,

    sh012

    website: https://www.dynamicslabs.io/

  • nickmanny Profile Picture
    nickmanny 136 on at
    RE: validation using javascript

    The following JavaScript shows how to validate email address using Regular Expression .

    function validateEmail(inText){
    const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    var email=document.getElementById(inText).value;
    if(re.test(String(email).toLowerCase()))
    {
    alert("Email is valid : " + email);
    }
    else
    {
    alert("Email is not valid : " + email);
    }
    }



  • Verified answer
    AbiRami Profile Picture
    AbiRami 516 on at
    RE: validation using javascript

    Hi,

    See the below article to validate the email address. A video clip is also provided to explain how to add the code in crm and its complete working

    softchief.com/.../email-address-validation-javascript-dynamics-crm

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: validation using javascript

    Hi,

    You can write the following code in javascript to validate email address in dynamics crm.

    function EmailTest(EmailField) {
      var Email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]{2,}$/;
      if (Email.test(EmailField)) {
        return true;
      } else {
        return false;
      }
    }
    
    function CheckEmailString(context) {
      try {
        var EmailString = Xrm.Page.getAttribute("emailaddress1").getValue();
        if (EmailString != null) {
          var Flag = true;
    
          if (!EmailTest(EmailString)) {
            Flag = false;
          }
          if (Flag != true) {
            alert("Please check if the email might contain invalid format. Note that only one email address is allowed for this.");
            }
        }
      } catch (err) {
        alert(err.message);
      }
    }
  • Verified answer
    Drew Poggemann Profile Picture
    Drew Poggemann 4 on at
    RE: validation using javascript

    Hi Ram,

    Here is an article that provides an example for you as well.  

    abhishekserjam.wordpress.com/.../crm-2013-form-field-formatting-through-javascript-6-email-field-validation

    Hope this helps!

    Thanks,

  • Verified answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: validation using javascript

    Hi Ram,

    As suggested by Guido, use onchange event to run some validation code. You can use regex to validate email. See example below.

    www.w3resource.com/.../email-validation.php

    Cheers,

    Nadeeja

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans