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 :
Microsoft Dynamics CRM (Archived)

how to get last 5 character of a field OR how to check "@gmail.com" is present in field using javascript

(0) ShareShare
ReportReport
Posted on by

how to get last 5 character of a field OR how to check "@gmail.com" is present in field  using javascript

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mithilesh Kumar Profile Picture
    10,047 on at

    Hi Ak,

    1. Are you trying to Validate your Email Field, if yes here is the code

    function checkEmail(emailField)

    {

    var email=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([azA-

    Z])+/;

    if(email.test(emailField))

    {

    // alert("true");

    return true;

    }

    }

    2. If you want to check whether text field contains "@gmail.com", then you can use indexOf() javascript function

    For reference you can look into this

    www.w3schools.com/.../jsref_indexof.asp

    Hope that helps

    Thanks

    Please mark my post as verified if you found it helpful

  • Verified answer
    Mathieu L Profile Picture
    100 on at

    If you want the last X characters, you can use the string.slice() method.

    var myStr = "Hello world!";

    var myRes = str.slice(-4);

    myRes => rld!

  • Verified answer
    Saroj Das Profile Picture
    3,355 on at

    HI AK, Mithilesh has already given the solution if you want to validate email Id. Also if you want to get last five characters of a string, then you should try this.

    var member = "My Name is Saroj";
    
    var last5 = member.slice(-5);
    
    alert(last5);  O/P Saroj

    Thanks

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans